pub struct SchemaBuilder { /* private fields */ }Expand description
Declaration order never matters: build sorts types by name and fields by
ID before encoding, so equivalent declarations produce identical schema ids.
Implementations§
Source§impl SchemaBuilder
impl SchemaBuilder
pub fn new() -> SchemaBuilder
Sourcepub fn set_default(
self,
struct_name: &str,
field_id: u16,
default: Value,
) -> SchemaBuilder
pub fn set_default( self, struct_name: &str, field_id: u16, default: Value, ) -> SchemaBuilder
Give a scalar field a custom default: the value a reader synthesizes
via StructReader::get_or_default when the field is absent. default
must be a scalar Value matching the field’s type (Value::Enum for
an enum field). Applied at build.
pub fn add_struct( self, name: &str, fields: Vec<(u16, &str, Dt)>, ) -> SchemaBuilder
Sourcepub fn add_dense_struct(
self,
name: &str,
fields: Vec<(u16, &str, Dt)>,
) -> SchemaBuilder
pub fn add_dense_struct( self, name: &str, fields: Vec<(u16, &str, Dt)>, ) -> SchemaBuilder
A dense struct stores no presence bitmap: every field is always present (encoding with one missing is an error). Smaller and slightly faster to read; use for records whose fields are all mandatory, e.g. geometric points, samples, matrix rows.
Sourcepub fn add_packed_struct(
self,
name: &str,
fields: Vec<(u16, &str, Dt)>,
) -> SchemaBuilder
pub fn add_packed_struct( self, name: &str, fields: Vec<(u16, &str, Dt)>, ) -> SchemaBuilder
A packed struct stores a presence bitmap followed by slots for the present fields only. Field offsets are recovered in O(1) with popcount rank queries over the bitmap — sparse-data wire sizes without giving up zero-copy random access or paying for per-object vtables. Limited to 64 fields. Best for wide records that are usually sparse (events with many optional attributes, config with many defaults).