Struct relm4::AsyncFactorySender
source · pub struct AsyncFactorySender<C: AsyncFactoryComponent> { /* private fields */ }
Expand description
Contains senders to send and receive messages from a Component
.
Implementations§
source§impl<C: AsyncFactoryComponent> AsyncFactorySender<C>
impl<C: AsyncFactoryComponent> AsyncFactorySender<C>
sourcepub fn input_sender(&self) -> &Sender<C::Input>
pub fn input_sender(&self) -> &Sender<C::Input>
Retrieve the sender for input messages.
Useful to forward inputs from another component. If you just need to send input messages,
input()
is more concise.
sourcepub fn output_sender(&self) -> &Sender<C::Output>
pub fn output_sender(&self) -> &Sender<C::Output>
Retrieve the sender for output messages.
Useful to forward outputs from another component. If you just need to send output messages,
output()
is more concise.
sourcepub fn command_sender(&self) -> &Sender<C::CommandOutput>
pub fn command_sender(&self) -> &Sender<C::CommandOutput>
Retrieve the sender for command output messages.
Useful to forward outputs from another component. If you just need to send output messages,
command()
is more concise.
sourcepub fn command<Cmd, Fut>(&self, cmd: Cmd)where
Cmd: FnOnce(Sender<C::CommandOutput>, ShutdownReceiver) -> Fut + Send + 'static,
Fut: Future<Output = ()> + Send,
pub fn command<Cmd, Fut>(&self, cmd: Cmd)where Cmd: FnOnce(Sender<C::CommandOutput>, ShutdownReceiver) -> Fut + Send + 'static, Fut: Future<Output = ()> + Send,
Spawns an asynchronous command.
You can bind the the command to the lifetime of the component
by using a ShutdownReceiver
.
sourcepub fn spawn_command<Cmd>(&self, cmd: Cmd)where
Cmd: FnOnce(Sender<C::CommandOutput>) + Send + 'static,
pub fn spawn_command<Cmd>(&self, cmd: Cmd)where Cmd: FnOnce(Sender<C::CommandOutput>) + Send + 'static,
Spawns a synchronous command.
This is particularly useful for CPU-intensive background jobs that need to run on a thread-pool in the background.
If you expect the component to be dropped while the command is running take care while sending messages!
sourcepub fn oneshot_command<Fut>(&self, future: Fut)where
Fut: Future<Output = C::CommandOutput> + Send + 'static,
pub fn oneshot_command<Fut>(&self, future: Fut)where Fut: Future<Output = C::CommandOutput> + Send + 'static,
Spawns a future that will be dropped as soon as the factory component is shut down.
Essentially, this is a simpler version of Self::command()
.
sourcepub fn spawn_oneshot_command<Cmd>(&self, cmd: Cmd)where
Cmd: FnOnce() -> C::CommandOutput + Send + 'static,
pub fn spawn_oneshot_command<Cmd>(&self, cmd: Cmd)where Cmd: FnOnce() -> C::CommandOutput + Send + 'static,
Spawns a synchronous command that will be dropped as soon as the factory component is shut down.
Essentially, this is a simpler version of Self::spawn_command()
.