Expand description
Byte-level wire codec for log segments.
A segment is an app-supplied magic header plus a sequence of entries. Each
entry is one op (encoded through the Op trait), a delta-encoded
timestamp, an optional user id (server mode), and a truncated blake3
integrity check. The magic identifies the application and is supplied by
the caller to Encoder::new / Decoder::new.
This module is generic over the op vocabulary E: Op: the framing here
(header, timestamp deltas, UUID dictionary compression, blake3 trailer,
expungement markers) knows nothing about any particular op. Each data
domain implements Op for its own op type — for example the table op
vocabulary in ubiquisync-tables.
Structs§
- Decoded
Logs - The result of decoding a whole segment, including the end state needed to append more entries to it.
- Decoder
- Streaming decoder for one segment: reads the header on construction, then yields entries one at a time, carrying the cross-entry state (timestamp base, UUID dictionary) that delta- and dictionary-decoding need.
- Encoder
- Streaming encoder for one segment: writes the header on construction, then appends entries, carrying the cross-entry state (timestamp base, UUID dictionary) that delta- and dictionary-encoding need.
- Entry
Buffer Reader - Decodes one log entry’s body — the read counterpart to
EntryBufferWriter. Feeds bytes through the rolling hash and resolves dictionary-compressed UUIDs. - Entry
Buffer Writer - 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.
- OpIndex
Entry - The indexable form of an op: its tag plus the
key/valuesplit of its body. SeeIndexableOp. - Reader
- A thin
BufReadwrapper that the codec reads a segment from, tracking position only enough to answeris_eof.
Enums§
- Codec
Error - An error encoding or decoding the log wire format.
- Decoded
Entry - One decoded entry: a live log entry or an expunged-entry marker.
Constants§
- FLAG_
DEVICE - Segment mode flag: device mode — attribution is implicit from the peer directory, so entries carry no user id.
- FLAG_
SERVER - Segment mode flag: server mode — every entry carries an explicit user id.
- TAG_
EXPUNGED - Reserved entry tag marking an expunged entry: the tag followed by the 32-byte blake3 hash of the original entry, with no body, no timestamp delta, and no integrity-check suffix. Domain op vocabularies must not reuse this tag.
Traits§
- Indexable
Op - An
Opthat can also be split into an indexable(tag, key, value)triple for the SQL op-log.keyis the indexable identity (such as table + primary key).valueis the op’s remaining payload. - Op
- An op vocabulary that can be encoded to / decoded from the log wire format.