Struct async_io_converse::ReceivedMessage
source · 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.