Struct IpcReceiver
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§
§impl<T> IpcReceiver<T>where
T: for<'de> Deserialize<'de> + Serialize,
impl<T> IpcReceiver<T>where
T: for<'de> Deserialize<'de> + Serialize,
pub 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.
pub 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§
§impl<T> Debug for IpcReceiver<T>where
T: Debug,
impl<T> Debug for IpcReceiver<T>where
T: Debug,
§impl<'de, T> Deserialize<'de> for IpcReceiver<T>
impl<'de, T> Deserialize<'de> for IpcReceiver<T>
§fn deserialize<D>(
deserializer: D,
) -> Result<IpcReceiver<T>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
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
§impl<T> Serialize for IpcReceiver<T>
impl<T> Serialize for IpcReceiver<T>
§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
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> 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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more