[][src]Struct broadcaster::BroadcastChannel

pub struct BroadcastChannel<T, S = UnboundedSender<T>, R = UnboundedReceiver<T>> where
    T: Send + Clone + 'static,
    S: Send + Sync + Unpin + Clone + Sink<T>,
    R: Unpin + Stream<Item = T>, 
{ /* fields omitted */ }

A broadcast channel, wrapping any clonable Stream and Sink to have every message sent to every receiver.

Methods

impl<T: Send + Clone> BroadcastChannel<T>[src]

pub fn new() -> Self[src]

Create a new unbounded channel. Requires the default-channels feature.

impl<T: Send + Clone> BroadcastChannel<T, Sender<T>, Receiver<T>>[src]

pub fn with_cap(cap: usize) -> Self[src]

Create a new bounded channel with a specific capacity. Requires the default-channels feature.

pub fn try_send(&self, item: &T) -> Result<(), TrySendError<T>>[src]

Try sending a value on a bounded channel. Requires the default-channels feature.

impl<T, S, R> BroadcastChannel<T, S, R> where
    T: Send + Clone + 'static,
    S: Send + Sync + Unpin + Clone + Sink<T>,
    R: Unpin + Stream<Item = T>, 
[src]

pub fn with_ctor(ctor: Arc<dyn Fn() -> (S, R) + Send + Sync>) -> Self[src]

Construct a new channel from any Sink and Stream. For proper functionality, cloning a Sender will create a new sink that also sends data to Receiver.

pub async fn send<'_, '_>(&'_ self, item: &'_ T) -> Result<(), S::Error>[src]

Send an item to all receivers in the channel, including this one. This is because futures-channel does not support comparing a sender and receiver. If this is not the desired behavior, you must handle it yourself.

pub fn recv(&mut self) -> impl Future<Output = Option<T>> + '_[src]

Receive a single value from the channel.

Trait Implementations

impl<T, S, R> Drop for BroadcastChannel<T, S, R> where
    T: Send + Clone + 'static,
    S: Send + Sync + Unpin + Clone + Sink<T>,
    R: Unpin + Stream<Item = T>, 
[src]

impl<T, S, R> Clone for BroadcastChannel<T, S, R> where
    T: Send + Clone + 'static,
    S: Send + Sync + Unpin + Clone + Sink<T>,
    R: Unpin + Stream<Item = T>, 
[src]

impl<T, S, R> Debug for BroadcastChannel<T, S, R> where
    T: Send + Clone + 'static,
    S: Send + Sync + Unpin + Clone + Debug + Sink<T>,
    R: Unpin + Debug + Stream<Item = T>, 
[src]

Auto Trait Implementations

impl<T, S, R> Send for BroadcastChannel<T, S, R> where
    R: Send

impl<T, S, R> Unpin for BroadcastChannel<T, S, R>

impl<T, S, R> Sync for BroadcastChannel<T, S, R> where
    R: Sync

impl<T, S = UnboundedSender<T>, R = UnboundedReceiver<T>> !UnwindSafe for BroadcastChannel<T, S, R>

impl<T, S = UnboundedSender<T>, R = UnboundedReceiver<T>> !RefUnwindSafe for BroadcastChannel<T, S, R>

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]