Skip to main content

KeyReceiver

Struct KeyReceiver 

Source
pub struct KeyReceiver<K: Key, V: Value> { /* private fields */ }
Expand description

A receiver for messages for a specific key.

Created via KeySender::subscribe.

Implementations§

Source§

impl<K: Key, V: Value> KeyReceiver<K, V>

Source

pub async fn recv(&mut self) -> Result<V, RecvError>

Receive the next message for this key, waiting asynchronously. See, tokio::sync::broadcast::Receiver::recv for more details.

Source

pub async fn try_recv(&mut self) -> Result<V, TryRecvError>

Try to receive the next message for this key without waiting.. See, tokio::sync::broadcast::Receiver::try_recv for more details.

Source

pub fn blocking_recv(&mut self) -> Result<V, RecvError>

Receive the next message for this key, blocking the current thread. Only use in synchronous contexts. See, tokio::sync::broadcast::Receiver::blocking_recv for more details.

Source

pub fn to_async_stream(self) -> impl Stream<Item = Result<V, RecvError>>

Consume this receiver and convert it into a stream of messages for this key.

Trait Implementations§

Source§

impl<K: Key, V: Value> Drop for KeyReceiver<K, V>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<K, V> Freeze for KeyReceiver<K, V>
where K: Freeze,

§

impl<K, V> RefUnwindSafe for KeyReceiver<K, V>
where K: RefUnwindSafe,

§

impl<K, V> Send for KeyReceiver<K, V>

§

impl<K, V> Sync for KeyReceiver<K, V>

§

impl<K, V> Unpin for KeyReceiver<K, V>
where K: Unpin,

§

impl<K, V> UnsafeUnpin for KeyReceiver<K, V>
where K: UnsafeUnpin,

§

impl<K, V> UnwindSafe for KeyReceiver<K, V>
where K: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.