pub fn encode_frame(
schema_version: SchemaVersion,
event_type: &EventType,
payload: &Payload,
metadata: Option<&Metadata>,
) -> Result<EncodedFrame, WireError>Expand description
Build one frame buffer with payload aligned to PAYLOAD_ALIGN.
Argument order: (schema_version, &event_type, &payload, metadata).
payload precedes metadata to keep the optional argument trailing per
Rust API conventions. Emits the current format (V2).
Layout:
[u8 frame_format_version][u32 LE schema_version]
[u16 LE event_type_len][u32 LE meta_len][event_type bytes]
[metadata bytes if any][padding zero-bytes][payload bytes]meta_len == u32::MAX is the absent-metadata sentinel.
All field invariants (UTF-8, size caps, schema_version > 0) live on
the value newtypes (EventType, Payload, Metadata,
SchemaVersion) — by the time inputs reach this function they are
already wire-encodable. The only remaining failure mode is arithmetic
overflow when combining lengths into the final frame size.
§Errors
Returns WireError::FrameLengthOverflow if the assembled frame
would overflow usize on the target platform.