Struct IpcReceiver

Source
pub struct IpcReceiver<T> { /* private fields */ }
Expand description

Receiving end of a channel using serialized messages.

§Examples

§Blocking IO

let response = rx.recv().unwrap();
println!("Received data...");

§Non-blocking IO

loop {
    match rx.try_recv() {
        Ok(res) => {
            // Do something interesting wth your result
            println!("Received data...");
            break;
        },
        Err(_) => {
            // Do something else useful while we wait
            println!("Still waiting...");
        }
    }
}

§Embedding Receivers

let (tx, rx) = ipc::channel().unwrap();
let (embedded_tx, embedded_rx) = ipc::channel().unwrap();
// Send the IpcReceiver
tx.send(embedded_rx).unwrap();
// Receive the sent IpcReceiver
let received_rx = rx.recv().unwrap();
// Receive any data sent to the received IpcReceiver
let rx_data = received_rx.recv().unwrap();

§Implementation details

Each IpcReceiver is backed by the OS specific implementations of OsIpcReceiver.

Implementations§

Source§

impl<T> IpcReceiver<T>
where T: for<'de> Deserialize<'de> + Serialize,

Source

pub fn recv(&self) -> Result<T, Box<ErrorKind>>

Blocking receive.

Source

pub fn try_recv(&self) -> Result<T, Box<ErrorKind>>

Non-blocking receive

Source

pub fn to_opaque(self) -> OpaqueIpcReceiver

Erase the type of the channel.

Useful for adding routes to a RouterProxy.

Trait Implementations§

Source§

impl<T> Debug for IpcReceiver<T>
where T: Debug,

Source§

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

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

impl<'de, T> Deserialize<'de> for IpcReceiver<T>

Source§

fn deserialize<D>( deserializer: D, ) -> Result<IpcReceiver<T>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T> Serialize for IpcReceiver<T>

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<T> !Freeze for IpcReceiver<T>

§

impl<T> !RefUnwindSafe for IpcReceiver<T>

§

impl<T> Send for IpcReceiver<T>
where T: Send,

§

impl<T> !Sync for IpcReceiver<T>

§

impl<T> Unpin for IpcReceiver<T>
where T: Unpin,

§

impl<T> UnwindSafe for IpcReceiver<T>
where T: UnwindSafe,

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>,

Source§

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>,

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,