Skip to main content

OwnedBinaryPayload

Struct OwnedBinaryPayload 

Source
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>

Source

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).

Source

pub fn contents(&self) -> (&[u8], u8)

The contents of the buffer.

Source

pub fn total_bytes(&self) -> usize

The total bytes needed to store this, including the header.

Source

pub fn into_inner(self) -> O

Unwraps this into the raw storage backing it.

Source

pub fn as_ptr(&self) -> *const BinaryPayload

Gets a const pointer to the start of the message’s buffer.

Source

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.

Source

pub unsafe fn from_ptr(ptr: NonNull<BinaryPayload>) -> Self

Takes ownership of the given pointer.

§Safety

You must provide a valid pointer, allocated by (or equivalent to one allocated by) Self::new. For instance, passing a pointer allocated by malloc to OwnedBinaryPayload::<Vec<u8>>::from_ptr is not allowed.

Trait Implementations§

Source§

impl<Owner: Debug + Buffer> Debug for OwnedBinaryPayload<Owner>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Owner> Freeze for OwnedBinaryPayload<Owner>
where Owner: Freeze,

§

impl<Owner> RefUnwindSafe for OwnedBinaryPayload<Owner>
where Owner: RefUnwindSafe,

§

impl<Owner> Send for OwnedBinaryPayload<Owner>
where Owner: Send,

§

impl<Owner> Sync for OwnedBinaryPayload<Owner>
where Owner: Sync,

§

impl<Owner> Unpin for OwnedBinaryPayload<Owner>
where Owner: Unpin,

§

impl<Owner> UnsafeUnpin for OwnedBinaryPayload<Owner>
where Owner: UnsafeUnpin,

§

impl<Owner> UnwindSafe for OwnedBinaryPayload<Owner>
where Owner: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.