pub struct Payload { /* private fields */ }Expand description
A payload can be sent over the transport.
Implementations§
Source§impl Payload
impl Payload
Sourcepub fn new(header_size: usize, data_size: usize) -> Payload
pub fn new(header_size: usize, data_size: usize) -> Payload
Creates a new payload with the given buffer.
Sourcepub fn header_mut(&mut self) -> &mut [u8] ⓘ
pub fn header_mut(&mut self) -> &mut [u8] ⓘ
Returns the mutable header section of the payload.
Sourcepub fn truncate(&mut self, len: usize)
pub fn truncate(&mut self, len: usize)
Truncate the payload to the given length.
This will truncate the data section of the payload, the header section will not be affected.
Sourcepub fn split_mut(&mut self) -> (&mut [u8], &mut [u8])
pub fn split_mut(&mut self) -> (&mut [u8], &mut [u8])
Split the payload into header and data.
The first element of the tuple is the header and the second element is the data.
Sourcepub fn split(self) -> (BytesMut, BytesMut)
pub fn split(self) -> (BytesMut, BytesMut)
Split the payload into header and data.
The first element of the tuple is the header and the second element is the data.
Sourcepub fn into_bytes(self) -> Bytes
pub fn into_bytes(self) -> Bytes
Consumes the payload and returns its inner buffer as a Bytes.
This is zero-copy when this is the only reference to the buffer (which is the common case for freshly-created payloads).
Trait Implementations§
impl Eq for Payload
impl StructuralPartialEq for Payload
Auto Trait Implementations§
impl Freeze for Payload
impl RefUnwindSafe for Payload
impl Send for Payload
impl Sync for Payload
impl Unpin for Payload
impl UnsafeUnpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more