pub struct EntryBufferWriter<'a> { /* private fields */ }Expand description
Encodes one log entry’s body: accumulates bytes while feeding a rolling blake3 hash, and deduplicates UUIDs against a dictionary shared across the segment’s entries.
Implementations§
Source§impl<'a> EntryBufferWriter<'a>
impl<'a> EntryBufferWriter<'a>
Sourcepub fn new(uuid_dict: &'a mut HashMap<Uuid, u32>) -> Self
pub fn new(uuid_dict: &'a mut HashMap<Uuid, u32>) -> Self
Create a writer that shares uuid_dict for UUID dictionary compression
across the entries of one segment.
Sourcepub fn write_byte(&mut self, b: u8)
pub fn write_byte(&mut self, b: u8)
Append a single raw byte.
Sourcepub fn write_varint(&mut self, v: u64)
pub fn write_varint(&mut self, v: u64)
Append v as an unsigned varint (7 data bits per byte, little-endian).
Sourcepub fn write_blob(&mut self, data: &[u8])
pub fn write_blob(&mut self, data: &[u8])
Append a length-prefixed byte string: a varint length, then the bytes.
Sourcepub fn write_u16_le(&mut self, v: u16)
pub fn write_u16_le(&mut self, v: u16)
Append a u16 in little-endian order.
Sourcepub fn write_zigzag(&mut self, n: i64)
pub fn write_zigzag(&mut self, n: i64)
Append a signed integer as a zigzag-encoded varint.
Sourcepub fn write_uuid(&mut self, data: &Uuid)
pub fn write_uuid(&mut self, data: &Uuid)
Write a UUID using dictionary compression. The canonical hash always sees the raw 16 bytes regardless of whether the buffer gets a dict reference or an inline literal.
Sourcepub fn write_delta(&mut self, current: u64, last: u64) -> Result<(), CodecError>
pub fn write_delta(&mut self, current: u64, last: u64) -> Result<(), CodecError>
Write a delta-encoded timestamp. Timestamps within a segment must be monotonically non-decreasing.
Sourcepub fn finalize(self) -> (Vec<u8>, Hash)
pub fn finalize(self) -> (Vec<u8>, Hash)
Finalize the entry: appends truncated blake3 hash as integrity check bytes and returns the encoded buffer plus the full hash.
Sourcepub fn into_bytes(self) -> Vec<u8> ⓘ
pub fn into_bytes(self) -> Vec<u8> ⓘ
Return just the encoded body, without the truncated-hash integrity
trailer that finalize appends. Used by callers that
reuse the wire encoding for storage and supply their own framing — e.g.
the SQL op-log index codec, which stores the raw key/value bytes and
has no use for a per-blob integrity hash.