Skip to main content

encode_fixed

Function encode_fixed 

Source
pub fn encode_fixed<T: IntoBytes + Immutable>(
    msg_type: u32,
    body: &T,
) -> IpcMessage
Expand description

Encode a fixed-size repr(C) struct as an IpcMessage.

The body is written directly into payload[0..size_of::<T>()]. Panics in debug if T exceeds PAYLOAD_CAPACITY; in release the write silently truncates.

§Example

use strat9_abi::ipc_codec::encode_fixed;

#[derive(FromBytes, IntoBytes)]
#[repr(C)]
struct StatReq { ino: u64, flags: u32 }

let msg = encode_fixed(0x10, &StatReq { ino: 42, flags: 0 });
assert_eq!(msg.msg_type, 0x10);