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].

This module also defines the shared VFS scheme opcodes (OPCODE_*) used as msg_type values on the wire: scheme servers must import them from here instead of redeclaring local copies.

§Conventions

  • Fixed-size structs are kept ≤ 48 bytes by convention : well under IpcMessage::PAYLOAD_CAPACITY (240) : so they can be embedded in messages that also carry an inline blob.
  • Variable-length path/data fields use an InlineBlobHeader prefix and may exploit the full 240-byte payload capacity.
  • 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_payload::{OpenRequest, OpenReply, OPCODE_OPEN};

// Encode an open request with path "/tmp/test"
let msg = OpenRequest::encode(OPCODE_OPEN, 0x02, "/tmp/test").unwrap();

// A server parses the request...
let (flags, path) = OpenRequest::parse(&msg.payload).unwrap();
assert_eq!(path, "/tmp/test");

// ...and builds a typed reply, which the client parses back.
let reply = OpenReply {
    status: 0,
    file_id: 42,
    size: 1024,
    file_flags: 0x01,
};

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.

Constants§

OPCODE_CLOSE
Wire msg_type for a close request.
OPCODE_CREATE_DIR
Wire msg_type for a create-directory request.
OPCODE_CREATE_FILE
Wire msg_type for a create-file request.
OPCODE_OPEN
Wire msg_type for an open request.
OPCODE_READ
Wire msg_type for a read request.
OPCODE_READDIR
Wire msg_type for a readdir request.
OPCODE_UNLINK
Wire msg_type for an unlink request.
OPCODE_WRITE
Wire msg_type for a write request.