pub struct Envelope<S>(/* private fields */);Expand description
Type-erased mailbox item for service S: a typed message dispatch or a topic operation.
Usually constructed with Envelope::new, Envelope::new_with_result_channel,
Envelope::new_subscribe_topic, or Envelope::new_publish_topic, then handled
by Envelope::handle inside the service run loop.
Implementations§
Source§impl<S> Envelope<S>
impl<S> Envelope<S>
Sourcepub fn new<M>(message: M) -> Self
pub fn new<M>(message: M) -> Self
Wrap a message for fire-and-forget delivery (no result sent to a caller).
Sourcepub fn new_with_result_channel<M>(
message: M,
result_channel: Option<Sender<M::Result>>,
) -> Self
pub fn new_with_result_channel<M>( message: M, result_channel: Option<Sender<M::Result>>, ) -> Self
Wrap a message and optionally send the handler’s return value on result_channel.
When result_channel is None, behaves like Self::new.
Sourcepub fn new_subscribe_topic<T>(topic: T, result_channel: Sender<T::Item>) -> Self
pub fn new_subscribe_topic<T>(topic: T, result_channel: Sender<T::Item>) -> Self
Register a one-shot subscriber for a specific topic value.
Sourcepub fn new_publish_topic<T>(topic: T, item: T::Item) -> Self
pub fn new_publish_topic<T>(topic: T, item: T::Item) -> Self
Publish one item to a specific topic value.
Sourcepub fn new_subscribe_all_topic<T>(
topic: T,
result_channel: UnboundedSender<T::Item>,
) -> Self
pub fn new_subscribe_all_topic<T>( topic: T, result_channel: UnboundedSender<T::Item>, ) -> Self
Register a subscriber waiting for all future publications.
Auto Trait Implementations§
impl<S> Freeze for Envelope<S>
impl<S> !RefUnwindSafe for Envelope<S>
impl<S> Send for Envelope<S>
impl<S> !Sync for Envelope<S>
impl<S> Unpin for Envelope<S>
impl<S> UnsafeUnpin for Envelope<S>
impl<S> !UnwindSafe for Envelope<S>
Blanket Implementations§
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
Mutably borrows from an owned value. Read more