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 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
.
Implementations§
source§impl<T> IpcReceiver<T>where
T: for<'de> Deserialize<'de> + Serialize,
impl<T> IpcReceiver<T>where
T: for<'de> Deserialize<'de> + Serialize,
sourcepub fn try_recv(&self) -> Result<T, TryRecvError>
pub fn try_recv(&self) -> Result<T, TryRecvError>
Non-blocking receive
sourcepub fn try_recv_timeout(&self, duration: Duration) -> Result<T, TryRecvError>
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.
sourcepub fn to_opaque(self) -> OpaqueIpcReceiver
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>
impl<T: Debug> Debug for IpcReceiver<T>
source§impl<'de, T> Deserialize<'de> for IpcReceiver<T>
impl<'de, T> Deserialize<'de> for IpcReceiver<T>
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. 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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more