Struct aldrin::PendingReceiver

source ·
pub struct PendingReceiver<T: Deserialize> { /* private fields */ }
Expand description

A claimed receiver that is waiting for the channel to become established.

PendingReceivers are used to wait until some client has claimed the sending end of the channel. This is done with the established function.

Implementations§

source§

impl<T: Deserialize> PendingReceiver<T>

source

pub async fn close(&mut self) -> Result<(), Error>

Closes the receiver without consuming it.

When closing a PendingReceiver, it will no longer be possible to claim the sender.

When the sender has already been claimed, the situation is a little bit more complicated. The sender is notified asynchronously about the receiver’s closing. It will, sooner or later, receive an error when sending an item.

§Examples
§Closing a receiver while the sender hasn’t been claimed yet
use aldrin::Error;

let (sender, mut receiver) = handle.create_channel_with_claimed_receiver::<u32>(16).await?;

// Close the receiver.
receiver.close().await?;

// For the sender, an error will be returned when trying to claim it.
let err = sender.claim().await.unwrap_err();
assert_eq!(err, Error::InvalidChannel);
source

pub async fn established(self) -> Result<Receiver<T>, Error>

Waits until the channel has been established.

A channel is established when both ends have been claimed. An error is returned when the sender has been closed instead of claimed.

source

pub fn cast<U: Deserialize>(self) -> PendingReceiver<U>

Casts the item type to a different type.

Trait Implementations§

source§

impl<T: Debug + Deserialize> Debug for PendingReceiver<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for PendingReceiver<T>

§

impl<T> !RefUnwindSafe for PendingReceiver<T>

§

impl<T> Send for PendingReceiver<T>

§

impl<T> Sync for PendingReceiver<T>

§

impl<T> Unpin for PendingReceiver<T>

§

impl<T> !UnwindSafe for PendingReceiver<T>

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>,

§

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>,

§

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.