Struct aldrin::PendingSender

source ·
pub struct PendingSender<T: Serialize + ?Sized> { /* private fields */ }
Expand description

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

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

Implementations§

source§

impl<T: Serialize + ?Sized> PendingSender<T>

source

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

Closes the sender without consuming it.

When closing a PendingSender, it will no longer be possible to claim the receiver. If it has already been claimed, then it will receive None, indicating that the channel has been closed.

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

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

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

// For the receiver, an error will be returned when trying to claim it.
let err = receiver.claim(16).await.unwrap_err();
assert_eq!(err, Error::InvalidChannel);
§Closing a sender while the receiver has already been claimed
use aldrin::Error;

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

// Claim the receiver.
let mut receiver = receiver.claim(16).await?;

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

// The receiver will receive None.
assert_eq!(receiver.next_item().await, Ok(None));
source

pub async fn established(self) -> Result<Sender<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 receiver has been closed instead of claimed.

source

pub fn cast<U: Serialize + ?Sized>(self) -> PendingSender<U>

Casts the item type to a different type.

Trait Implementations§

source§

impl<T: Debug + Serialize + ?Sized> Debug for PendingSender<T>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T: ?Sized> Freeze for PendingSender<T>

§

impl<T> !RefUnwindSafe for PendingSender<T>

§

impl<T: ?Sized> Send for PendingSender<T>

§

impl<T: ?Sized> Sync for PendingSender<T>

§

impl<T: ?Sized> Unpin for PendingSender<T>

§

impl<T> !UnwindSafe for PendingSender<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.