[][src]Struct ductile::ChannelReceiver

pub struct ChannelReceiver<T> { /* fields omitted */ }

The channel part that receives data. It is generic over the type of messages sent in the channel. The type of the messages must match between sender and receiver.

This type is not Clone since the channel is multiple producers, single consumer, just like std::sync::mpsc.

Implementations

impl<T> ChannelReceiver<T> where
    T: 'static + DeserializeOwned
[src]

pub fn recv(&self) -> Result<T>[src]

Receive a message from the channel. This method will block until the other end sends a message.

If the other end used send_raw this method panics since the channel corrupts.

let (sender, receiver) = new_local_channel();
sender.send(42);
let num: i32 = receiver.recv().unwrap();
assert_eq!(num, 42);

pub fn recv_raw(&self) -> Result<Vec<u8>>[src]

Receive some raw data from the channel. This method will block until the other end sends some data.

If the other end used send this method panics since the channel corrupts.

let (sender, receiver) = new_local_channel::<()>();
sender.send_raw(&vec![1, 2, 3]);
let data: Vec<u8> = receiver.recv_raw().unwrap();
assert_eq!(data, vec![1, 2, 3]);

pub fn change_type<T2>(self) -> ChannelReceiver<T2>[src]

Given this is a remote channel, change the type of the message. Will panic if this is a ChannelReceiver::Local.

This function is useful for implementing a protocol where the message types change during the execution, for example because initially there is an handshake message, followed by the actual protocol messages.

let receiver: ChannelReceiver<i32> = receiver.change_type();
let receiver: ChannelReceiver<String> = receiver.change_type();

Auto Trait Implementations

impl<T> !RefUnwindSafe for ChannelReceiver<T>

impl<T> Send for ChannelReceiver<T> where
    T: Send

impl<T> !Sync for ChannelReceiver<T>

impl<T> Unpin for ChannelReceiver<T> where
    T: Unpin

impl<T> UnwindSafe for ChannelReceiver<T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

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