pub struct Message<T: ?Sized> { /* private fields */ }Expand description
An owned VPP message buffer containing a T.
The message can be sent to a client using Registration::send_message.
Important invariant:
Tmust have an alignment of 1 (e.g. by#[repr(packed)])
Implementations§
Source§impl<T> Message<T>
impl<T> Message<T>
Sourcepub fn new(value: T) -> Self
pub fn new(value: T) -> Self
Allocate a VPP message and initialise it by copying value into the
newly-allocated buffer.
§Panics
Panics if align_of::<T>() != 1 because the VPP API message allocator does not provide
alignment guarantees; generated message structs are expected to be packed.
Sourcepub fn new_uninit() -> Message<MaybeUninit<T>>
pub fn new_uninit() -> Message<MaybeUninit<T>>
Allocate an uninitialised VPP message buffer for T.
This returns a Message<MaybeUninit<T>>. Use Self::write or Self::assume_init
after manually initialising the contents.
§Panics
Panics if align_of::<T>() != 1 for the same reason as new.
Source§impl<T: ?Sized> Message<T>
impl<T: ?Sized> Message<T>
Sourcepub fn into_raw(m: Self) -> *mut T
pub fn into_raw(m: Self) -> *mut T
Consume the Message and return the raw pointer to the underlying buffer
The returned pointer becomes the caller’s responsibility. The Message destructor will
not run for m and the underlying buffer will not be freed by Rust; callers must ensure
the buffer is eventually freed (for example by passing it to VPP or calling
vl_msg_api_free).
Not a method on Message to avoid clashing with application methods of the same name on
the underlying type.
Source§impl<T> Message<MaybeUninit<T>>
impl<T> Message<MaybeUninit<T>>
Sourcepub unsafe fn assume_init(self) -> Message<T>
pub unsafe fn assume_init(self) -> Message<T>
Convert a Message<MaybeUninit<T>> into a Message<T> without performing any
initialisation checks
§Safety
The caller must ensure that the underlying buffer is fully initialised for T. If the
memory is not properly initialised, using the resulting Message<T> is undefined
behaviour.