Skip to main content

Receiver

Struct Receiver 

Source
pub(crate) struct Receiver<T> {
    shared: Arc<Shared<T>>,
    is_waiting_for_msg: bool,
}
Expand description

The receiving end of the oneshot channel.

Fields§

§shared: Arc<Shared<T>>

State shared with the Sender.

§is_waiting_for_msg: bool

Are we still waiting to receive the message?

Implementations§

Source§

impl<T> Receiver<T>

Source

pub(crate) fn new() -> Self

A new receiver without a Sender.

Source

pub(crate) fn is_waiting_for_msg(&self) -> bool

Is this receiver waiting for a message?

This is true if the receiver has a Sender that it has not read a message from yet.

If this returns false, then a new Sender can be successfully created.

Source

pub(crate) fn new_sender(&mut self) -> Option<Sender<T>>

Create a new Sender. Can only have one sender at a time.

Returns None if we’ve previously created a sender and we haven’t read its message yet.

Source

pub(crate) fn guarantee_new_sender(&mut self) -> Option<SenderGuarantee<'_, T>>

Provides a type that can be converted into a new Sender.

This can be useful if you don’t want a new Sender yet, but you want a guarantee that a sender can be created later.

Returns None if we’ve previously created a sender and we haven’t read its message yet.

Source

pub(crate) fn recv<'a>(&'a mut self) -> Result<ReceiverFuture<'a, T>, NoSender>

Receive the message.

Source

pub(crate) fn try_recv(&mut self) -> Result<Option<T>, RecvError>

Try to receive a message without blocking.

Source

fn recv_impl(&mut self) -> Option<Result<T, SenderDropped>>

The shared implementation to receive the message.

The “message has not yet been set” path is quick (just an atomic load) so its cheap to check.

Returns None if there’s no update. Returns Some if we have the message or the sender was dropped.

Trait Implementations§

Source§

impl<T: Debug> Debug for Receiver<T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for Receiver<T>

§

impl<T> !UnwindSafe for Receiver<T>

§

impl<T> Forget for Receiver<T>

§

impl<T> Freeze for Receiver<T>
where Arc<Shared<T>>: Freeze,

§

impl<T> Move for Receiver<T>

§

impl<T> Send for Receiver<T>
where Arc<Shared<T>>: Send,

§

impl<T> Sync for Receiver<T>
where Arc<Shared<T>>: Sync,

§

impl<T> Unpin for Receiver<T>
where Arc<Shared<T>>: Unpin,

§

impl<T> UnsafeUnpin for Receiver<T>
where Arc<Shared<T>>: UnsafeUnpin,

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more