#[repr(C, packed(1))]pub struct VsockHeader {
pub src_cid: u64,
pub dst_cid: u64,
pub src_port: u32,
pub dst_port: u32,
pub len: u32,
pub socket_type: u16,
pub op: u16,
pub flags: u32,
pub buf_alloc: u32,
pub fwd_cnt: u32,
}Expand description
Vsock packet header.
Fields§
§src_cid: u64Source CID.
dst_cid: u64Destination CID.
src_port: u32Source port.
dst_port: u32Destination port.
len: u32Payload length.
socket_type: u16Socket type (stream = 1).
op: u16Operation.
flags: u32Flags.
buf_alloc: u32Buffer allocation.
fwd_cnt: u32Forward count.
Implementations§
Source§impl VsockHeader
impl VsockHeader
Sourcepub const SIZE: usize = 44
pub const SIZE: usize = 44
Header size in bytes.
The VirtIO vsock spec defines the header as exactly 44 bytes (packed).
We cannot use mem::size_of::<Self>() because Rust adds trailing padding
to satisfy the struct’s 8-byte alignment (from u64 fields), yielding 48.
The guest kernel sends and expects exactly 44 bytes per header.
Sourcepub const fn new(src: VsockAddr, dst: VsockAddr, op: VsockOp) -> VsockHeader
pub const fn new(src: VsockAddr, dst: VsockAddr, op: VsockOp) -> VsockHeader
Creates a new header.
Sourcepub fn from_bytes(bytes: &[u8]) -> Option<VsockHeader>
pub fn from_bytes(bytes: &[u8]) -> Option<VsockHeader>
Parses a vsock header from a byte slice.
Returns None if the slice is too short.
Trait Implementations§
Source§impl Clone for VsockHeader
impl Clone for VsockHeader
Source§fn clone(&self) -> VsockHeader
fn clone(&self) -> VsockHeader
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for VsockHeader
Auto Trait Implementations§
impl Freeze for VsockHeader
impl RefUnwindSafe for VsockHeader
impl Send for VsockHeader
impl Sync for VsockHeader
impl Unpin for VsockHeader
impl UnsafeUnpin for VsockHeader
impl UnwindSafe for VsockHeader
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more