indexbus_msg/
constants.rs

1/// Envelope magic for v1 ("USM1").
2pub const MAGIC: [u8; 4] = *b"USM1";
3
4/// Minimum v1 header length in bytes.
5///
6/// Layout (little-endian):
7/// - magic: `[u8; 4]`
8/// - flags: u16
9/// - codec_id: u8
10/// - header_len: u8
11/// - schema_id: u64
12/// - msg_type: u32
13/// - msg_version: u16
14/// - payload_len: u16
15pub const V1_HEADER_LEN: usize = 24;
16
17/// Absolute maximum bytes available per slot.
18///
19/// This is the maximum available for `header_len + payload_len` when the envelope is stored in an
20/// IndexBus slot.
21pub const SLOT_CAPACITY: usize = indexbus_abi::INDEXBUS_SLOT_DATA_SIZE;
22
23/// Maximum payload length for a v1 message, excluding any optional appended fields.
24#[inline]
25pub const fn max_payload_len_v1() -> usize {
26    SLOT_CAPACITY - V1_HEADER_LEN
27}