#[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 fn from_bytes(bytes: &[u8]) -> Option<Self>
pub fn from_bytes(bytes: &[u8]) -> Option<Self>
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