pub struct Receiver { /* private fields */ }Expand description
Receiver half of a Unix socket transport for receiving JSON-RPC messages.
Implementations§
Source§impl Receiver
impl Receiver
Sourcepub async fn receive(&mut self) -> Result<MessageWithFds>
pub async fn receive(&mut self) -> Result<MessageWithFds>
Receive a message, returning an error on connection close.
See also receive_opt which returns Ok(None)
on connection close instead of an error.
Sourcepub async fn receive_opt(&mut self) -> Result<Option<MessageWithFds>>
pub async fn receive_opt(&mut self) -> Result<Option<MessageWithFds>>
Receive a message, returning Ok(None) on connection close.
This is a convenience method that converts Error::ConnectionClosed
to Ok(None), which is useful for receiver loops:
ⓘ
while let Some(msg) = receiver.receive_opt().await? {
// handle message
}See also receive which returns an error on
connection close.
Auto Trait Implementations§
impl Freeze for Receiver
impl RefUnwindSafe for Receiver
impl Send for Receiver
impl Sync for Receiver
impl Unpin for Receiver
impl UnsafeUnpin for Receiver
impl UnwindSafe for Receiver
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