Struct aldrin::UnboundReceiver

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

A receiver that is not bound to any particular client.

UnboundReceivers are used to transfer receivers to some other client, typically by returning them from function calls.

When creating a channel the resulting UnclaimedReceiver can be unbound and sent to another client.

It is worth noting that this type implements Copy and Clone. As such (and because it is not bound to any client), it will not close the receiving end of a channel. This is the main difference from UnclaimedReceiver.

Implementations§

source§

impl<T: Deserialize> UnboundReceiver<T>

source

pub fn bind(self, client: Handle) -> UnclaimedReceiver<T>

Binds the receiver to a client.

See also claim to bind and claim the receiver in one step.

§Examples
use aldrin::{Receiver, UnclaimedReceiver};

// Assume this receiver has been returned from some function call.
// let receiver: UnboundReceiver<u32> = ...

// Bind it to the local client. The explicit type is shown here only for the sake of the
// example.
let receiver: UnclaimedReceiver<u32> = receiver.bind(handle.clone());

// Afterwards, it can be claimed.
let receiver: Receiver<u32> = receiver.claim(16).await?;
source

pub async fn claim( self, client: Handle, capacity: u32 ) -> Result<Receiver<T>, Error>

Binds the receiver to a client and claims it.

This function is equivalent to receiver.bind(client).claim().

See UnclaimedReceiver::claim for explanation of the cases in which this function can fail.

A capacity of 0 is treated as if 1 was specificed instead.

§Examples
use aldrin::Receiver;

// Assume this receiver has been returned from some function call.
// let receiver: UnboundReceiver<u32> = ...

// Bind it to the local client and claim it, so that it can immediately be used. The
// explicit type here is given only for the sake of the example.
let receiver: Receiver<u32> = receiver.claim(handle.clone(), 16).await?;
source

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

Casts the item type to a different type.

Trait Implementations§

source§

impl<T: Clone + Deserialize> Clone for UnboundReceiver<T>

source§

fn clone(&self) -> UnboundReceiver<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

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

source§

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

Formats the value using the given formatter. Read more
source§

impl<T: Deserialize> Deserialize for UnboundReceiver<T>

source§

fn deserialize( deserializer: Deserializer<'_, '_> ) -> Result<Self, DeserializeError>

source§

impl<T: PartialEq + Deserialize> PartialEq for UnboundReceiver<T>

source§

fn eq(&self, other: &UnboundReceiver<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: Deserialize> Serialize for UnboundReceiver<T>

source§

fn serialize(&self, serializer: Serializer<'_>) -> Result<(), SerializeError>

source§

impl<T: Copy + Deserialize> Copy for UnboundReceiver<T>

source§

impl<T: Eq + Deserialize> Eq for UnboundReceiver<T>

source§

impl<T: Deserialize> StructuralPartialEq for UnboundReceiver<T>

Auto Trait Implementations§

§

impl<T> Freeze for UnboundReceiver<T>

§

impl<T> RefUnwindSafe for UnboundReceiver<T>

§

impl<T> Send for UnboundReceiver<T>

§

impl<T> Sync for UnboundReceiver<T>

§

impl<T> Unpin for UnboundReceiver<T>

§

impl<T> UnwindSafe for UnboundReceiver<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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.