#[repr(C, packed)]
pub struct VhostUserMsgHeader<R: Req> { request: u32, flags: u32, size: u32, _r: PhantomData<R>, }
Expand description

Common message header for vhost-user requests and replies. A vhost-user message consists of 3 header fields and an optional payload. All numbers are in the machine native byte order.

Fields§

§request: u32§flags: u32§size: u32§_r: PhantomData<R>

Implementations§

source§

impl<R: Req> VhostUserMsgHeader<R>

source

pub fn new(request: R, flags: u32, size: u32) -> Self

Create a new instance of VhostUserMsgHeader.

source

pub fn get_code(&self) -> Result<R, R::Error>

Get message type.

source

pub fn set_code(&mut self, request: R)

Set message type.

source

pub fn get_version(&self) -> u32

Get message version number.

source

pub fn set_version(&mut self, ver: u32)

Set message version number.

source

pub fn is_reply(&self) -> bool

Check whether it’s a reply message.

source

pub fn set_reply(&mut self, is_reply: bool)

Mark message as reply.

source

pub fn is_need_reply(&self) -> bool

Check whether reply for this message is requested.

source

pub fn set_need_reply(&mut self, need_reply: bool)

Mark that reply for this message is needed.

source

pub fn is_reply_for(&self, req: &VhostUserMsgHeader<R>) -> bool

Check whether it’s the reply message for the request req.

source

pub fn get_size(&self) -> u32

Get message size.

source

pub fn set_size(&mut self, size: u32)

Set message size.

Trait Implementations§

source§

impl<R: Req> AsBytes for VhostUserMsgHeader<R>where u32: AsBytes, PhantomData<R>: AsBytes,

§

fn as_bytes(&self) -> &[u8]

Gets the bytes of this value. Read more
§

fn as_bytes_mut(&mut self) -> &mut [u8] where Self: FromBytes,

Gets the bytes of this value mutably. Read more
§

fn write_to(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to bytes. Read more
§

fn write_to_prefix(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to the prefix of bytes. Read more
§

fn write_to_suffix(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to the suffix of bytes. Read more
source§

impl<R: Req> Clone for VhostUserMsgHeader<R>

source§

fn clone(&self) -> VhostUserMsgHeader<R>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<R: Req> Debug for VhostUserMsgHeader<R>

source§

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

Formats the value using the given formatter. Read more
source§

impl<R: Req> Default for VhostUserMsgHeader<R>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<R: Req> FromBytes for VhostUserMsgHeader<R>where u32: FromBytes, PhantomData<R>: FromBytes,

§

fn ref_from(bytes: &[u8]) -> Option<&Self>where Self: Sized,

Interprets the given bytes as a &Self without copying. Read more
§

fn ref_from_prefix(bytes: &[u8]) -> Option<&Self>where Self: Sized,

Interprets the prefix of the given bytes as a &Self without copying. Read more
§

fn ref_from_suffix(bytes: &[u8]) -> Option<&Self>where Self: Sized,

Interprets the suffix of the given bytes as a &Self without copying. Read more
§

fn mut_from(bytes: &mut [u8]) -> Option<&mut Self>where Self: Sized + AsBytes,

Interprets the given bytes as a &mut Self without copying. Read more
§

fn mut_from_prefix(bytes: &mut [u8]) -> Option<&mut Self>where Self: Sized + AsBytes,

Interprets the prefix of the given bytes as a &mut Self without copying. Read more
§

fn mut_from_suffix(bytes: &mut [u8]) -> Option<&mut Self>where Self: Sized + AsBytes,

Interprets the suffix of the given bytes as a &mut Self without copying. Read more
§

fn slice_from(bytes: &[u8]) -> Option<&[Self]>where Self: Sized,

Interprets the given bytes as a &[Self] without copying. Read more
§

fn slice_from_prefix(bytes: &[u8], count: usize) -> Option<(&[Self], &[u8])>where Self: Sized,

Interprets the prefix of the given bytes as a &[Self] with length equal to count without copying. Read more
§

fn slice_from_suffix(bytes: &[u8], count: usize) -> Option<(&[u8], &[Self])>where Self: Sized,

Interprets the suffix of the given bytes as a &[Self] with length equal to count without copying. Read more
§

fn mut_slice_from(bytes: &mut [u8]) -> Option<&mut [Self]>where Self: Sized + AsBytes,

Interprets the given bytes as a &mut [Self] without copying. Read more
§

fn mut_slice_from_prefix( bytes: &mut [u8], count: usize ) -> Option<(&mut [Self], &mut [u8])>where Self: Sized + AsBytes,

Interprets the prefix of the given bytes as a &mut [Self] with length equal to count without copying. Read more
§

fn mut_slice_from_suffix( bytes: &mut [u8], count: usize ) -> Option<(&mut [u8], &mut [Self])>where Self: Sized + AsBytes,

Interprets the suffix of the given bytes as a &mut [Self] with length equal to count without copying. Read more
§

fn read_from(bytes: &[u8]) -> Option<Self>where Self: Sized,

Reads a copy of Self from bytes. Read more
§

fn read_from_prefix(bytes: &[u8]) -> Option<Self>where Self: Sized,

Reads a copy of Self from the prefix of bytes. Read more
§

fn read_from_suffix(bytes: &[u8]) -> Option<Self>where Self: Sized,

Reads a copy of Self from the suffix of bytes. Read more
source§

impl<R: Req> FromZeroes for VhostUserMsgHeader<R>where u32: FromZeroes, PhantomData<R>: FromZeroes,

§

fn zero(&mut self)

Overwrites self with zeroes. Read more
§

fn new_zeroed() -> Selfwhere Self: Sized,

Creates an instance of Self from zeroed bytes. Read more
source§

impl<R: Req> PartialEq<VhostUserMsgHeader<R>> for VhostUserMsgHeader<R>

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: Req> VhostUserMsgValidator for VhostUserMsgHeader<T>

source§

fn is_valid(&self) -> bool

Validate message syntax only. It doesn’t validate message semantics such as protocol version number and dependency on feature flags etc.
source§

impl<R: Copy + Req> Copy for VhostUserMsgHeader<R>

Auto Trait Implementations§

§

impl<R> RefUnwindSafe for VhostUserMsgHeader<R>where R: RefUnwindSafe,

§

impl<R> Send for VhostUserMsgHeader<R>

§

impl<R> Sync for VhostUserMsgHeader<R>

§

impl<R> Unpin for VhostUserMsgHeader<R>where R: Unpin,

§

impl<R> UnwindSafe for VhostUserMsgHeader<R>where R: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.