yew_stdweb::agent

Trait Agent

Source
pub trait Agent: Sized + 'static {
    type Reach: Discoverer<Agent = Self>;
    type Message;
    type Input;
    type Output;

    // Required methods
    fn create(link: AgentLink<Self>) -> Self;
    fn update(&mut self, msg: Self::Message);
    fn handle_input(&mut self, msg: Self::Input, id: HandlerId);

    // Provided methods
    fn connected(&mut self, _id: HandlerId) { ... }
    fn disconnected(&mut self, _id: HandlerId) { ... }
    fn destroy(&mut self) { ... }
    fn name_of_resource() -> &'static str { ... }
    fn is_module() -> bool { ... }
}
Expand description

Declares the behavior of the agent.

Required Associated Types§

Source

type Reach: Discoverer<Agent = Self>

Reach capability of the agent.

Source

type Message

Type of an input message.

Source

type Input

Incoming message type.

Source

type Output

Outgoing message type.

Required Methods§

Source

fn create(link: AgentLink<Self>) -> Self

Creates an instance of an agent.

Source

fn update(&mut self, msg: Self::Message)

This method called on every update message.

Source

fn handle_input(&mut self, msg: Self::Input, id: HandlerId)

This method called on every incoming message.

Provided Methods§

Source

fn connected(&mut self, _id: HandlerId)

This method called on when a new bridge created.

Source

fn disconnected(&mut self, _id: HandlerId)

This method called on when a new bridge destroyed.

Source

fn destroy(&mut self)

This method called when the agent is destroyed.

Source

fn name_of_resource() -> &'static str

Represents the name of loading resorce for remote workers which have to live in a separate files.

Source

fn is_module() -> bool

Signifies if resource is a module. This has pending browser support.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§