pub struct IncomingMessage { /* private fields */ }Expand description
A message received from the channel: the text content, plus a reply slot that only questions have.
Returned by each channel’s receive method. Check IncomingMessage::wants_reply first —
for question messages, send the reply back with IncomingMessage::reply; notification messages have no reply slot.
See MpscChannel for a complete usage example.
Implementations§
Source§impl IncomingMessage
impl IncomingMessage
Sourcepub fn wants_reply(&self) -> bool
pub fn wants_reply(&self) -> bool
Whether this is a question (expects a reply); notifications return false.
Only messages that return true may call IncomingMessage::reply.
Sourcepub fn reply(self, answer: String) -> Result<(), ChannelError>
pub fn reply(self, answer: String) -> Result<(), ChannelError>
Sends back a reply; the message is consumed in the process, so it can only be replied to once.
§Errors
ChannelError::NoReply— this is a notification message and does not expect a reply;ChannelError::Closed— the asker has left (e.g.askwas cancelled or timed out), so nobody will receive the reply.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for IncomingMessage
impl !UnwindSafe for IncomingMessage
impl Freeze for IncomingMessage
impl Send for IncomingMessage
impl Sync for IncomingMessage
impl Unpin for IncomingMessage
impl UnsafeUnpin for IncomingMessage
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