Skip to main content

SchemaBuilder

Struct SchemaBuilder 

Source
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

Source

pub fn new() -> SchemaBuilder

Source

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.

Source

pub fn add_struct( self, name: &str, fields: Vec<(u16, &str, Dt)>, ) -> SchemaBuilder

Source

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.

Source

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).

Source

pub fn add_enum(self, name: &str, variants: Vec<(u32, &str)>) -> SchemaBuilder

Source

pub fn build(self, root: &str) -> Result<Schema>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.