pub fn encode_record(record: &CanonicalRecord, out: &mut Vec<u8>)Expand description
Encode a CanonicalRecord with its framing into the output buffer.
Framing: [1 byte opcode][varint body length][body].
§Examples
use mimir_core::canonical::{
encode_record, decode_record, CanonicalRecord, CheckpointRecord,
};
use mimir_core::{ClockTime, SymbolId};
let record = CanonicalRecord::Checkpoint(CheckpointRecord {
episode_id: SymbolId::new(42),
at: ClockTime::try_from_millis(1_700_000_000_000).expect("non-sentinel"),
memory_count: 3,
});
let mut bytes = Vec::new();
encode_record(&record, &mut bytes);
let (decoded, _used) = decode_record(&bytes).unwrap();
assert_eq!(decoded, record);