pub struct Duplex<S: Object, R: Object>(/* private fields */);
Expand description
A side of a bidirectional channel.
S
is the type of the objects this side sends via the channel and the other side receives, R
is the type of the objects the other side sends via the channel and this side receives.
Implementations§
source§impl<S: Object, R: Object> Duplex<S, R>
impl<S: Object, R: Object> Duplex<S, R>
sourcepub fn recv(&mut self) -> Result<Option<R>>
pub fn recv(&mut self) -> Result<Option<R>>
Receive a value from the other side.
Returns Ok(None)
if the other side has dropped the channel.
sourcepub fn request(&mut self, value: &S) -> Result<R>
pub fn request(&mut self, value: &S) -> Result<R>
Send a value from the other side and wait for a response immediately.
If the other side closes the channel before responding, an error is returned.
pub fn into_sender(self) -> Sender<S>
pub fn into_receiver(self) -> Receiver<R>
Trait Implementations§
source§impl<S: Object, R: Object> FromRawFd for Duplex<S, R>
Available on Unix only.
impl<S: Object, R: Object> FromRawFd for Duplex<S, R>
Available on Unix only.
source§unsafe fn from_raw_fd(fd: RawHandle) -> Self
unsafe fn from_raw_fd(fd: RawHandle) -> Self
Constructs a new instance of
Self
from the given raw file
descriptor. Read moresource§impl<S: Object, R: Object> IntoRawFd for Duplex<S, R>
Available on Unix only.
impl<S: Object, R: Object> IntoRawFd for Duplex<S, R>
Available on Unix only.
source§fn into_raw_fd(self) -> RawHandle
fn into_raw_fd(self) -> RawHandle
Consumes this object, returning the raw underlying file descriptor. Read more
source§impl<S: Object, R: Object> NonTrivialObject for Duplex<S, R>
impl<S: Object, R: Object> NonTrivialObject for Duplex<S, R>
source§fn serialize_self_non_trivial(&self, s: &mut Serializer)
fn serialize_self_non_trivial(&self, s: &mut Serializer)
Serialize a single object into a serializer.
source§unsafe fn deserialize_self_non_trivial(d: &mut Deserializer) -> Result<Self>
unsafe fn deserialize_self_non_trivial(d: &mut Deserializer) -> Result<Self>
Deserialize a single object from a deserializer. Read more
Auto Trait Implementations§
impl<S, R> Freeze for Duplex<S, R>
impl<S, R> RefUnwindSafe for Duplex<S, R>
impl<S, R> Send for Duplex<S, R>
impl<S, R> Sync for Duplex<S, R>
impl<S, R> Unpin for Duplex<S, R>
impl<S, R> UnwindSafe for Duplex<S, R>
Blanket Implementations§
source§impl<T> AsRawHandle for Twhere
T: AsRawFd,
impl<T> AsRawHandle for Twhere
T: AsRawFd,
fn as_raw_handle(&self) -> RawHandle
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
source§impl<T> FromRawHandle for Twhere
T: FromRawFd,
impl<T> FromRawHandle for Twhere
T: FromRawFd,
unsafe fn from_raw_handle(handle: RawHandle) -> Selfwhere
Self: Sized,
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> IntoRawHandle for Twhere
T: IntoRawFd,
impl<T> IntoRawHandle for Twhere
T: IntoRawFd,
fn into_raw_handle(self) -> RawHandlewhere
Self: Sized,
source§impl<T> Object for Twhere
T: NonTrivialObject,
impl<T> Object for Twhere
T: NonTrivialObject,
source§fn serialize_self(&self, s: &mut Serializer)
fn serialize_self(&self, s: &mut Serializer)
Serialize a single object into a serializer.
source§fn serialize_slice(elements: &[T], s: &mut Serializer)
fn serialize_slice(elements: &[T], s: &mut Serializer)
Serialize an array of objects into a serializer.
source§unsafe fn deserialize_self(d: &mut Deserializer) -> Result<T, Error>
unsafe fn deserialize_self(d: &mut Deserializer) -> Result<T, Error>
Deserialize a single object from a deserializer. Read more