pub struct OwnedBinaryPayload<Owner: Buffer>(/* private fields */);Expand description
A binary message owned by some storage.
This is an owned, memory-managed version of BinaryPayload.
The O type manages the memory where the payload lives.
Vec<u8> is one such manager and can be used when ownership
of the data does not need to transit through PAM.
Implementations§
Source§impl<O: Buffer> OwnedBinaryPayload<O>
impl<O: Buffer> OwnedBinaryPayload<O>
Sourcepub fn new(data: &[u8], type_: u8) -> Result<Self, TooBigError>
pub fn new(data: &[u8], type_: u8) -> Result<Self, TooBigError>
Allocates a new OwnedBinaryPayload.
This will return a TooBigError if you try to allocate too much
(more than BinaryPayload::MAX_SIZE).
Sourcepub fn total_bytes(&self) -> usize
pub fn total_bytes(&self) -> usize
The total bytes needed to store this, including the header.
Sourcepub fn into_inner(self) -> O
pub fn into_inner(self) -> O
Unwraps this into the raw storage backing it.
Sourcepub fn as_ptr(&self) -> *const BinaryPayload
pub fn as_ptr(&self) -> *const BinaryPayload
Gets a const pointer to the start of the message’s buffer.
Sourcepub fn into_ptr(self) -> NonNull<BinaryPayload>
pub fn into_ptr(self) -> NonNull<BinaryPayload>
Consumes ownership of this message and converts it to a raw pointer to the start of the message.
To clean this up, you should eventually pass it into Self::from_ptr
with the same O ownership type.