#[repr(C)]pub struct InlineBlobHeader {
pub len: u16,
pub kind: u16,
}Expand description
Minimal framing header for variable-length data embedded in an IPC payload.
Layout (4 bytes): [len: u16, kind: u16].
len: number of data bytes that follow this header.kind: discriminator (e.g.0= path,1= blob data).
This lets you embed a variable-length segment in the 240-byte payload without external allocators or serde.
§Example
ⓘ
use strat9_abi::ipc_codec::InlineBlobHeader;
let mut payload = [0u8; 240];
// Write a file path at offset 4
InlineBlobHeader::write(&mut payload, 4, 0, b"/etc/passwd").unwrap();
// Parse it back
let hdr = InlineBlobHeader::parse(&payload, 4).unwrap();
assert_eq!(hdr.len, 11); // "/etc/passwd".len()
assert_eq!(hdr.kind, 0);Fields§
§len: u16Number of data bytes following this header.
kind: u16Discriminator: 0 = path, 1 = blob data, etc.
Implementations§
Source§impl InlineBlobHeader
impl InlineBlobHeader
Sourcepub fn write(
payload: &mut [u8],
off: usize,
kind: u16,
data: &[u8],
) -> Option<()>
pub fn write( payload: &mut [u8], off: usize, kind: u16, data: &[u8], ) -> Option<()>
Write InlineBlobHeader(len, kind) followed by data into
payload[off..].
Returns None if the header + data do not fit in the payload slice.
Sourcepub fn parse(payload: &[u8], off: usize) -> Option<Self>
pub fn parse(payload: &[u8], off: usize) -> Option<Self>
Parse an InlineBlobHeader from payload[off..].
Returns None if the 4 header bytes are out of bounds.
Sourcepub fn total_size(&self) -> usize
pub fn total_size(&self) -> usize
Return the total wire size of this header + its inline data.
Trait Implementations§
Source§impl Clone for InlineBlobHeader
impl Clone for InlineBlobHeader
Source§fn clone(&self) -> InlineBlobHeader
fn clone(&self) -> InlineBlobHeader
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 InlineBlobHeader
Source§impl Debug for InlineBlobHeader
impl Debug for InlineBlobHeader
Source§impl FromBytes for InlineBlobHeaderwhere
u16: FromBytes,
impl FromBytes for InlineBlobHeaderwhere
u16: FromBytes,
Source§impl FromZeros for InlineBlobHeaderwhere
u16: FromZeros,
impl FromZeros for InlineBlobHeaderwhere
u16: FromZeros,
impl Immutable for InlineBlobHeaderwhere
u16: Immutable,
Source§impl IntoBytes for InlineBlobHeader
impl IntoBytes for InlineBlobHeader
§fn as_mut_bytes(&mut self) -> &mut [u8]where
Self: FromBytes,
fn as_mut_bytes(&mut self) -> &mut [u8]where
Self: FromBytes,
Gets the bytes of this value mutably. Read more
§fn write_to(&self, dst: &mut [u8]) -> Result<(), SizeError<&Self, &mut [u8]>>where
Self: Immutable,
fn write_to(&self, dst: &mut [u8]) -> Result<(), SizeError<&Self, &mut [u8]>>where
Self: Immutable,
Source§impl TryFromBytes for InlineBlobHeaderwhere
u16: TryFromBytes,
impl TryFromBytes for InlineBlobHeaderwhere
u16: TryFromBytes,
§fn try_read_from_bytes(
source: &[u8],
) -> Result<Self, ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
fn try_read_from_bytes(
source: &[u8],
) -> Result<Self, ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
§fn try_read_from_prefix(
source: &[u8],
) -> Result<(Self, &[u8]), ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
fn try_read_from_prefix(
source: &[u8],
) -> Result<(Self, &[u8]), ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
§fn try_read_from_suffix(
source: &[u8],
) -> Result<(&[u8], Self), ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
fn try_read_from_suffix(
source: &[u8],
) -> Result<(&[u8], Self), ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
Auto Trait Implementations§
impl Freeze for InlineBlobHeader
impl RefUnwindSafe for InlineBlobHeader
impl Send for InlineBlobHeader
impl Sync for InlineBlobHeader
impl Unpin for InlineBlobHeader
impl UnsafeUnpin for InlineBlobHeader
impl UnwindSafe for InlineBlobHeader
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