pub struct FileBuilder { /* private fields */ }Expand description
Build a complete generation-1 .verit file in memory.
No I/O, deterministic output: the same records added in the same order
always produce the same bytes. That makes it the reference writer the golden
file corpus and the ports’ conformance suites are checked against
(spec §11.5). For incremental, crash-safe mutation of a file on disk, use
FileWriter.
Implementations§
Source§impl FileBuilder
impl FileBuilder
pub fn new() -> FileBuilder
Sourcepub fn with_record_checksums(self) -> FileBuilder
pub fn with_record_checksums(self) -> FileBuilder
Record a CRC-32 per record, setting OPT_RECORD_CRC in the header.
The footer’s CRC proves a commit was not torn; it says nothing about the record bytes. For a file meant to be read years from now, this is the difference between detecting bit rot and trusting it. Costs four bytes per record, and readers without the feature are unaffected.
Must be called before the first record.
Sourcepub fn append(&mut self, schema: &Schema, value: &Value) -> Result<u64>
pub fn append(&mut self, schema: &Schema, value: &Value) -> Result<u64>
Encode value against schema and append it as the next record,
returning its record id. The message is written hash-only — the
schema goes to the file’s schema section once, however many records use
it.
Sourcepub fn append_message(&mut self, schema: &Schema, bytes: &[u8]) -> Result<u64>
pub fn append_message(&mut self, schema: &Schema, bytes: &[u8]) -> Result<u64>
Append an already-encoded message together with its writer schema,
returning its record id. Accepts hash-only and inline-schema messages
alike; the schema id in the message must match schema.
Sourcepub fn append_message_with_id(
&mut self,
schema: &Schema,
bytes: &[u8],
id: u64,
) -> Result<u64>
pub fn append_message_with_id( &mut self, schema: &Schema, bytes: &[u8], id: u64, ) -> Result<u64>
Append a record under an explicit id — the compaction path, where ids must be preserved, not reassigned. Ids must be handed over strictly ascending.
Sourcepub fn append_self_describing(&mut self, bytes: &[u8]) -> Result<u64>
pub fn append_self_describing(&mut self, bytes: &[u8]) -> Result<u64>
Append a self-describing (inline-schema) message, lifting its schema out
of the message itself. The record is stored verbatim, inline schema and
all — use append_message to store it hash-only.
Sourcepub fn reserve_next_record_id(&mut self, n: u64) -> &mut Self
pub fn reserve_next_record_id(&mut self, n: u64) -> &mut Self
Ensure the finished file’s next_record_id is at least n.
Compaction uses this to carry a writer’s id counter across a rewrite: removing the highest-id record must not let that id be handed out again.