pub struct AsyncComponentSender<C: AsyncComponent> { /* private fields */ }
Expand description
Contains senders to send and receive messages from a Component
.
Implementations§
source§impl<C: AsyncComponent> AsyncComponentSender<C>
impl<C: AsyncComponent> AsyncComponentSender<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)
pub fn spawn_command<Cmd>(&self, cmd: Cmd)
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)
pub fn oneshot_command<Fut>(&self, future: Fut)
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)
pub fn spawn_oneshot_command<Cmd>(&self, cmd: Cmd)
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()
.
Trait Implementations§
source§impl<C: AsyncComponent> Clone for AsyncComponentSender<C>
impl<C: AsyncComponent> Clone for AsyncComponentSender<C>
Auto Trait Implementations§
impl<C> Freeze for AsyncComponentSender<C>
impl<C> RefUnwindSafe for AsyncComponentSender<C>
impl<C> Send for AsyncComponentSender<C>
impl<C> Sync for AsyncComponentSender<C>
impl<C> Unpin for AsyncComponentSender<C>
impl<C> UnwindSafe for AsyncComponentSender<C>
Blanket Implementations§
source§impl<C> AsyncPosition<()> for C
impl<C> AsyncPosition<()> for C
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)