pub struct Receiver<T> where
    T: Send
{ /* private fields */ }
Expand description

The receiving half of a channel. This half can only be owned by one thread.

To receive messages sent to the channel, call async_recv or one of the blocking receive methods.

Implementations

Attempts to wait for a value on this receiver, returning an error if the corresponding channel has hung up.

The future returned by this function completes when there is data available or it’s not possible for more data to be sent (because all senders were dropped). Once a message is sent to the corresponding sender, this receiver will wake up and return that message.

If the corresponding sender has disconnected, or it disconnects while this call is blocking, this call will wake up and return Err to indicate that no more messages can ever be received on this channel. However, since channels are buffered, messages sent before the disconnect will still be properly received.

Attempts to return a pending value on this receiver without blocking.

This method will never block the caller in order to wait for data to become available. Instead, this will always return immediately with a possible option of pending data on the channel.

This is useful for a flavor of “optimistic check” before deciding to block on a receiver.

Compared with recv, this function has two failure cases instead of one (one for disconnection, one for an empty buffer).

Attempts to wait for a value on this receiver, returning an error if the corresponding channel has hung up.

This function will always block the current thread if there is no data available and it’s possible for more data to be sent (at least one sender still exists). Once a message is sent to the corresponding sender, this receiver will wake up and return that message.

If the corresponding sender has disconnected, or it disconnects while this call is blocking, this call will wake up and return Err to indicate that no more messages can ever be received on this channel. However, since channels are buffered, messages sent before the disconnect will still be properly received.

Attempts to wait for a value on this receiver, returning an error if the corresponding channel has hung up, or if it waits more than timeout.

This function will always block the current thread if there is no data available and it’s possible for more data to be sent (at least one sender still exists). Once a message is sent to the corresponding sender, this receiver will wake up and return that message.

If the corresponding sender has disconnected, or it disconnects while this call is blocking, this call will wake up and return Err to indicate that no more messages can ever be received on this channel. However, since channels are buffered, messages sent before the disconnect will still be properly received.

Known Issues

There is currently a known issue in the inner std::sync::mpsc::Receiver that can cause recv_timeout to panic unexpectedly. See the explanation at std::sync::mpsc::Receiver::recv_timeout.

Returns an iterator that will block waiting for messages, but never panic. It will return None when the channel has hung up.

Returns an iterator that will attempt to yield all pending values. It will return None if there are no more pending values or if the channel has hung up. The iterator will never panic or block the user by waiting for values.

Trait Implementations

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

🔬 This is a nightly-only experimental API. (into_future)

The output that the future will produce on completion.

🔬 This is a nightly-only experimental API. (into_future)

Which kind of future are we turning this into?

🔬 This is a nightly-only experimental API. (into_future)

Creates a future from a value.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.