pub trait Worker:
Sized
+ Send
+ 'static {
type Init: 'static + Send;
type Input: 'static + Send + Debug;
type Output: 'static + Send + Debug;
// Required methods
fn init(init: Self::Init, sender: ComponentSender<Self>) -> Self;
fn update(&mut self, message: Self::Input, sender: ComponentSender<Self>);
}Expand description
Receives inputs and outputs in the background.
All types that implement Worker will also implement
Component automatically.
If you need more flexibility when using workers, you can
simply implement Component instead and set the Component::Widgets
and Component::Root types both to ().
This will still allow you to use all worker related methods because internally
a worker is just seen as a Component without widgets.
Required Associated Types§
Required Methods§
Sourcefn init(init: Self::Init, sender: ComponentSender<Self>) -> Self
fn init(init: Self::Init, sender: ComponentSender<Self>) -> Self
Defines the initial state of the worker.
Sourcefn update(&mut self, message: Self::Input, sender: ComponentSender<Self>)
fn update(&mut self, message: Self::Input, sender: ComponentSender<Self>)
Defines how inputs will bep processed
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.