pub enum Payload {
Inline,
Owned(Vec<u8>),
Bytes(Bytes),
Pooled(PooledBuf),
}Expand description
Payload storage for a frame.
Variants§
Inline
Payload bytes live inside MsgDescHot::inline_payload.
Owned(Vec<u8>)
Payload bytes are owned as a heap allocation.
Bytes(Bytes)
Payload bytes are stored in a ref-counted buffer (cheap clone).
Pooled(PooledBuf)
Payload bytes backed by a buffer pool (returns to pool on drop).
Placeholder for pooled buffers (see issue #46).
Implementations§
Source§impl Payload
impl Payload
Sourcepub fn as_slice<'a>(&'a self, desc: &'a MsgDescHot) -> &'a [u8] ⓘ
pub fn as_slice<'a>(&'a self, desc: &'a MsgDescHot) -> &'a [u8] ⓘ
Borrow the payload as a byte slice.
Sourcepub fn external_slice(&self) -> Option<&[u8]>
pub fn external_slice(&self) -> Option<&[u8]>
Borrow the payload as a byte slice without needing a descriptor.
Returns None for Payload::Inline, since inline bytes live inside
MsgDescHot.
Sourcepub fn len(&self, desc: &MsgDescHot) -> usize
pub fn len(&self, desc: &MsgDescHot) -> usize
Returns the payload length in bytes.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Payload
impl RefUnwindSafe for Payload
impl Send for Payload
impl Sync for Payload
impl Unpin for Payload
impl UnwindSafe for Payload
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