MessageData

Trait MessageData 

Source
pub trait MessageData: Sized + Debug {
    // Required methods
    fn copy_from_user(
        data: &mut dyn InputBuffer,
        limit: usize,
    ) -> Result<Self, Errno>;
    fn ptr(&self) -> Result<*const u8, Errno>;
    fn with_bytes<O, F: FnMut(&[u8]) -> Result<O, Errno>>(
        &self,
        f: F,
    ) -> Result<O, Errno>;
    fn len(&self) -> usize;
    fn split_off(&mut self, index: usize) -> Option<Self>;
    fn copy_to_user(&self, data: &mut dyn OutputBuffer) -> Result<usize, Errno>;
    fn clone_at_most(&self, limit: usize) -> Self;
    fn truncate(&mut self, limit: usize);
}
Expand description

Stores an arbitrary sequence of bytes.

Required Methods§

Source

fn copy_from_user( data: &mut dyn InputBuffer, limit: usize, ) -> Result<Self, Errno>

Copies data from user memory into a new MessageData object.

Source

fn ptr(&self) -> Result<*const u8, Errno>

Returns a pointer to this data.

Source

fn with_bytes<O, F: FnMut(&[u8]) -> Result<O, Errno>>( &self, f: F, ) -> Result<O, Errno>

Calls the provided function with this data’s bytes.

Source

fn len(&self) -> usize

Returns the number of bytes in the message.

Source

fn split_off(&mut self, index: usize) -> Option<Self>

Splits the message data at index.

After this call returns, at most at bytes will be stored in this MessageData, and any remaining bytes will be moved to the returned MessageData.

Source

fn copy_to_user(&self, data: &mut dyn OutputBuffer) -> Result<usize, Errno>

Copies the message out to the output buffer.

Returns the number of bytes that were read into the buffer.

Source

fn clone_at_most(&self, limit: usize) -> Self

Clones this data up to a limit.

Source

fn truncate(&mut self, limit: usize)

Truncates this data to the specified limit.

Does nothing if the limit is larger than the data’s size.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl MessageData for Arc<VmsplicePayload>

Source§

fn copy_from_user( _data: &mut dyn InputBuffer, _limit: usize, ) -> Result<Self, Errno>

Source§

fn ptr(&self) -> Result<*const u8, Errno>

Source§

fn with_bytes<O, F: FnMut(&[u8]) -> Result<O, Errno>>( &self, f: F, ) -> Result<O, Errno>

Source§

fn len(&self) -> usize

Source§

fn split_off(&mut self, limit: usize) -> Option<Self>

Source§

fn truncate(&mut self, limit: usize)

Source§

fn clone_at_most(&self, limit: usize) -> Self

Source§

fn copy_to_user(&self, data: &mut dyn OutputBuffer) -> Result<usize, Errno>

Source§

impl MessageData for Vec<u8>

Source§

fn copy_from_user( data: &mut dyn InputBuffer, limit: usize, ) -> Result<Self, Errno>

Source§

fn ptr(&self) -> Result<*const u8, Errno>

Source§

fn with_bytes<O, F: FnMut(&[u8]) -> Result<O, Errno>>( &self, f: F, ) -> Result<O, Errno>

Source§

fn len(&self) -> usize

Source§

fn split_off(&mut self, index: usize) -> Option<Self>

Source§

fn copy_to_user(&self, data: &mut dyn OutputBuffer) -> Result<usize, Errno>

Source§

fn clone_at_most(&self, limit: usize) -> Self

Source§

fn truncate(&mut self, limit: usize)

Implementors§