Function encode_header_into
pub fn encode_header_into(out: &mut [u8], hdr: Header) -> Result<usize, Error>Expand description
Encode a v1 header into out.
§Contract
- Writes exactly
V1_HEADER_LENbytes on success and returnsV1_HEADER_LEN. - Currently requires
hdr.header_len == V1_HEADER_LEN. - Rejects unknown flag bits for deterministic behavior.
- Validates
hdr.header_len + hdr.payload_len <= SLOT_CAPACITY. - Does not write any payload bytes; callers are expected to write the payload after the header.
§Errors
Returns Error::BufferTooSmall if out is shorter than V1_HEADER_LEN. Returns
Error::BadHeaderLen, Error::BadPayloadLen, or Error::UnknownFlags if the header is
structurally invalid.