pub struct IpcReceiver<T> {
    os_receiver: OsIpcReceiver,
    phantom: PhantomData<T>,
}
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 with 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.

Fields§

§os_receiver: OsIpcReceiver§phantom: PhantomData<T>

Implementations§

source§

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

source

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

Blocking receive.

source

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

Non-blocking receive

source

pub fn try_recv_timeout(&self, duration: Duration) -> Result<T, TryRecvError>

Blocks for up to the specified duration attempting to receive a message.

This may block for longer than the specified duration if the channel is busy. If your timeout exceeds the duration that your operating system can represent in milliseconds, this may block forever. At the time of writing, the smallest duration that may trigger this behavior is over 24 days.

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> Debug for IpcReceiver<T>

source§

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

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<Self, D::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::Ok, S::Error>where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

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

source§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,