Struct vmm_vhost::message::VhostUserMsgHeader

source ·
#[repr(C, packed(1))]
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 into_raw(self) -> [u32; 3]

source

pub fn from_raw(raw: [u32; 3]) -> Self

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> 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> PartialEq 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§

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> CloneToUninit for T
where T: Copy,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where 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 T
where 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 T
where 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.