Skip to main content

Module ipc_payload

Module ipc_payload 

Source
Expand description

Typed repr(C) payload structs for fixed-size IPC messages.

Each struct derives zerocopy’s FromBytes + IntoBytes + Immutable, enabling safe zero-cost cast to/from [IpcMessage] payloads via [encode_fixed] / [decode_fixed].

§Conventions

  • All sizes are ≤ 48 bytes (the payload capacity).
  • Variable-length path/data fields use an InlineBlobHeader prefix.
  • status == 0 means success; non-zero is an errno-compatible error code.
  • Padding fields are named _pad or _reserved and must be zero.

§Wire format

Messages are sent through IPC ports or channels as raw bytes. The msg_type field in the IpcMessage header identifies the operation. The payload field contains the struct-specific data.

§Example

use strat9_abi::ipc_codec::{encode_fixed, decode_fixed, put_str, InlineBlobHeader};
use strat9_abi::ipc_payload::{OpenRequest, OpenReply};

// Encode an open request with path "/tmp/test"
let mut msg = encode_fixed(0x01, &OpenRequest {
    flags: 0x02,  // WRITE
    path_hdr: InlineBlobHeader { len: 10, kind: 0 },
});
put_str(&mut msg.payload, 8, "/tmp/test").unwrap();

// Decode the reply
let reply: &OpenReply = decode_fixed(&reply_msg).unwrap();
assert_eq!(reply.status, 0); // success

Macros§

assert_payload_size 🔒

Structs§

CloseRequest
Close request.
CreateReply
Create reply.
CreateRequest
Create request (file or directory).
LseekReply
Lseek reply.
LseekRequest
Lseek request.
OpenReply
Open reply.
OpenRequest
Open request.
ReadReply
Read reply prefix (variable-length data follows at offset 8).
ReadRequest
Read request.
StatRequest
Stat request.
StatusReply
Minimal reply carrying only a status code.
TcpConnectReply
TCP connect reply.
TcpConnectRequest
TCP connect request.
WriteReply
Write reply.
WriteRequest
Write request with variable-length inline data.