pub struct Broadcaster<R: Clone = (), A = ()> {
    pub(crate) broadcaster: Sender<R>,
    pub(crate) shutdown_watcher: UnboundedReceiver<A>,
    pub(crate) mpsc_copy: UnboundedSender<A>,
}
Expand description

Allows signalling a shutdown, with a particular reason ShutdownReason<R> for the shutdown. Also allows for listening to an acknowledgement A of the shutdown from the various listeners.

If dropped, a shutdown of type ShutdownReason::BroadcasterClosed will occur.

Generics

  • R: The reason for initiating the shutdown. Can be helpful when there are multiple causes of a shutdown, and the listeners will clean up differently depending on the shutdown reason.
  • A: An acknowledgement of the shutdown, possibly containing any useful information that can be sent back to the ShutdownBroadcaster.

Fields

broadcaster: Sender<R>shutdown_watcher: UnboundedReceiver<A>mpsc_copy: UnboundedSender<A>

Implementations

Creates a new Listener to the Broadcaster.

Signals shutdown, with an optional reason. If no reason is provided, the listeners will get ShutdownReason::BroadcasterClosed.

Returns

Returns a channel to be used for receiving the shutdown acknowledgements.

Trait Implementations

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.