pub struct ReceivedMessage<W: AsyncWrite + Unpin, T: Serialize + DeserializeOwned + Unpin> { /* private fields */ }
Expand description
A message received from the connected peer, which you may choose to reply to.
Implementations§
Source§impl<W: AsyncWrite + Unpin, T: Serialize + DeserializeOwned + Unpin> ReceivedMessage<W, T>
impl<W: AsyncWrite + Unpin, T: Serialize + DeserializeOwned + Unpin> ReceivedMessage<W, T>
Sourcepub fn message(&self) -> &T
pub fn message(&self) -> &T
Peeks at the message, panicking if the message had already been taken prior.
Sourcepub fn message_opt(&self) -> Option<&T>
pub fn message_opt(&self) -> Option<&T>
Peeks at the message, returning None
if the message had already been taken prior.
Sourcepub fn take_message(&mut self) -> T
pub fn take_message(&mut self) -> T
Pulls the message from this, panicking if the message had already been taken prior.
Sourcepub fn take_message_opt(&mut self) -> Option<T>
pub fn take_message_opt(&mut self) -> Option<T>
Pulls the message from this, returning None
if the message had already been taken prior.
Sourcepub async fn reply(self, reply: T) -> Result<(), Error>
pub async fn reply(self, reply: T) -> Result<(), Error>
Sends the given message as a reply to this one. There are two ways for the peer to receive this reply
.await
both layers of AsyncWriteConverse::send or AsyncWriteConverse::send_timeout- They’ll receive it as the return value of AsyncWriteConverse::ask or AsyncWriteConverse::ask_timeout.
Auto Trait Implementations§
impl<W, T> Freeze for ReceivedMessage<W, T>where
T: Freeze,
impl<W, T> !RefUnwindSafe for ReceivedMessage<W, T>
impl<W, T> Send for ReceivedMessage<W, T>
impl<W, T> Sync for ReceivedMessage<W, T>
impl<W, T> Unpin for ReceivedMessage<W, T>
impl<W, T> !UnwindSafe for ReceivedMessage<W, T>
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