[][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> 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]

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> Sink<T> for &'_ BroadcastChannel<T, S, R> where
    T: Send + Clone + 'static,
    S: Send + Sync + Unpin + Clone + Sink<T>,
    R: Unpin + Stream<Item = T>, 
[src]

type Error = S::Error

The type of value produced by the sink when an error occurs.

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

type Error = S::Error

The type of value produced by the sink when an error occurs.

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

type Item = T

Values yielded by the stream.

Auto Trait Implementations

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

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

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

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

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

Blanket Implementations

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

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

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

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

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

impl<T, Item> SinkExt<Item> for T where
    T: Sink<Item> + ?Sized
[src]

impl<T> StreamExt for T where
    T: Stream + ?Sized
[src]

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

type Owned = T

The resulting type after obtaining ownership.

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<S, T, E> TryStream for S where
    S: Stream<Item = Result<T, E>> + ?Sized
[src]

type Ok = T

The type of successful values yielded by this future

type Error = E

The type of failures yielded by this future

impl<S> TryStreamExt for S where
    S: TryStream + ?Sized
[src]