pub struct Message<P: Payload> { /* private fields */ }Expand description
A message with a generic payload P.
Implementations§
Source§impl<P: Payload> Message<P>
impl<P: Payload> Message<P>
Sourcepub fn new(header: MessageHeader, payload: P) -> Self
pub fn new(header: MessageHeader, payload: P) -> Self
Construct a new message from a header and payload, fixing size and class.
Sourcepub fn with_payload<Q: Payload>(self, payload: Q) -> Message<Q>
pub fn with_payload<Q: Payload>(self, payload: Q) -> Message<Q>
Swap payloads while recalculating header fields.
Sourcepub fn map_payload<Q: Payload>(self, f: impl FnOnce(P) -> Q) -> Message<Q>
pub fn map_payload<Q: Payload>(self, f: impl FnOnce(P) -> Q) -> Message<Q>
Transform payloads while preserving header metadata correctly.
Sourcepub fn payload_mut(&mut self) -> &mut P
pub fn payload_mut(&mut self) -> &mut P
Mutable borrow of the payload.
Sourcepub fn header(&self) -> &MessageHeader
pub fn header(&self) -> &MessageHeader
Borrow the header.
Sourcepub fn header_mut(&mut self) -> &mut MessageHeader
pub fn header_mut(&mut self) -> &mut MessageHeader
Mutable borrow of the header.
Sourcepub fn into_parts(self) -> (MessageHeader, P)
pub fn into_parts(self) -> (MessageHeader, P)
Decompose into (header, payload).
Trait Implementations§
Source§impl<'a, P: Payload + 'a> Payload for &'a Message<P>
impl<'a, P: Payload + 'a> Payload for &'a Message<P>
Source§fn buffer_descriptor(&self) -> BufferDescriptor
fn buffer_descriptor(&self) -> BufferDescriptor
Return a descriptor containing the byte size of this payload.
Source§impl<P: Payload> Payload for Message<P>
impl<P: Payload> Payload for Message<P>
Source§fn buffer_descriptor(&self) -> BufferDescriptor
fn buffer_descriptor(&self) -> BufferDescriptor
Return a descriptor containing the byte size of this payload.
impl<P> Copy for Message<P>
Auto Trait Implementations§
impl<P> Freeze for Message<P>where
P: Freeze,
impl<P> RefUnwindSafe for Message<P>where
P: RefUnwindSafe,
impl<P> Send for Message<P>where
P: Send,
impl<P> Sync for Message<P>where
P: Sync,
impl<P> Unpin for Message<P>where
P: Unpin,
impl<P> UnsafeUnpin for Message<P>where
P: UnsafeUnpin,
impl<P> UnwindSafe for Message<P>where
P: UnwindSafe,
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