pub struct CommandEnvelope {
pub format_version: u32,
pub command_id: [u8; 16],
pub command_type: u32,
pub payload: Vec<u8>,
pub payload_sha256: [u8; 32],
}Expand description
The versioned, checksummed form of every persisted command.
Fields§
§format_version: u32Envelope format version; see COMMAND_ENVELOPE_FORMAT_VERSION.
command_id: [u8; 16]Unique identifier of this command (for idempotent apply).
command_type: u32Discriminant of the payload command; numbers are never reused.
payload: Vec<u8>Schema-evolution-safe encoded command payload. The envelope never interprets these bytes; unknown optional payload fields are preserved or ignored safely by the payload decoder.
payload_sha256: [u8; 32]SHA-256 over version, type, length, and payload.
Implementations§
Source§impl CommandEnvelope
impl CommandEnvelope
Sourcepub fn new(command_type: u32, command_id: [u8; 16], payload: Vec<u8>) -> Self
pub fn new(command_type: u32, command_id: [u8; 16], payload: Vec<u8>) -> Self
Builds an envelope at the current format version, computing the checksum.
Sourcepub fn checksum(
format_version: u32,
command_type: u32,
payload: &[u8],
) -> [u8; 32]
pub fn checksum( format_version: u32, command_type: u32, payload: &[u8], ) -> [u8; 32]
Computes the checksum covering type, version, length, and payload.
Sourcepub fn verify(&self) -> Result<(), EnvelopeError>
pub fn verify(&self) -> Result<(), EnvelopeError>
Fails closed unless the version is supported and the checksum matches.
Sourcepub fn encode(&self) -> Vec<u8> ⓘ
pub fn encode(&self) -> Vec<u8> ⓘ
Serializes to the canonical deterministic encoding: equal envelopes always produce byte-identical output.
Sourcepub fn decode(bytes: &[u8]) -> Result<Self, EnvelopeError>
pub fn decode(bytes: &[u8]) -> Result<Self, EnvelopeError>
Parses one envelope, verifying version and checksum (fails closed).
Trait Implementations§
Source§impl Clone for CommandEnvelope
impl Clone for CommandEnvelope
Source§fn clone(&self) -> CommandEnvelope
fn clone(&self) -> CommandEnvelope
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more