pub trait Worker: 'static + Sized {
type Reach: Discoverer<Worker = Self>;
type Message;
type Input;
type Output;
fn create(link: WorkerLink<Self>) -> Self;
fn update(&mut self, msg: Self::Message);
fn handle_input(&mut self, msg: Self::Input, id: HandlerId);
fn connected(&mut self, _id: HandlerId) { ... }
fn disconnected(&mut self, _id: HandlerId) { ... }
fn destroy(&mut self) { ... }
fn name_of_resource() -> &'static str { ... }
fn resource_path_is_relative() -> bool { ... }
fn is_module() -> bool { ... }
}
Expand description
Declares the behavior of the worker.
Required Associated Types§
Required Methods§
sourcefn create(link: WorkerLink<Self>) -> Self
fn create(link: WorkerLink<Self>) -> Self
Creates an instance of an worker.
sourcefn handle_input(&mut self, msg: Self::Input, id: HandlerId)
fn handle_input(&mut self, msg: Self::Input, id: HandlerId)
This method called on every incoming message.
Provided Methods§
sourcefn disconnected(&mut self, _id: HandlerId)
fn disconnected(&mut self, _id: HandlerId)
This method called on when a new bridge destroyed.
sourcefn name_of_resource() -> &'static str
fn name_of_resource() -> &'static str
Represents the name of loading resource for remote workers which have to live in a separate files.
sourcefn resource_path_is_relative() -> bool
fn resource_path_is_relative() -> bool
Indicates whether the name of the resource is relative.
The default implementation returns false
, which will cause the result
returned by Self::name_of_resource
to be interpreted as an absolute
URL. If true
is returned, it will be interpreted as a relative URL.