pub struct Schema {
pub name: String,
pub fields: Vec<SchemaField>,
pub key_field_index: Option<usize>,
pub is_validated: bool,
}Expand description
Represents a schema for a DBC file
Fields§
§name: StringName of the schema
fields: Vec<SchemaField>Fields in the schema
key_field_index: Option<usize>Index of the key field, if any
is_validated: boolWhether the schema is validated
Implementations§
Source§impl Schema
impl Schema
Sourcepub fn add_field(&mut self, field: SchemaField) -> &mut Self
pub fn add_field(&mut self, field: SchemaField) -> &mut Self
Add a field to the schema
Sourcepub fn set_key_field_index(&mut self, index: usize) -> &mut Self
pub fn set_key_field_index(&mut self, index: usize) -> &mut Self
Set the key field by index
Sourcepub fn set_key_field(&mut self, name: &str) -> &mut Self
pub fn set_key_field(&mut self, name: &str) -> &mut Self
Set the key field by name
§Panics
Panics if the field with the given name is not found in the schema. This is intentional as it indicates a programming error in schema definition.
Sourcepub fn try_set_key_field(&mut self, name: &str) -> Result<&mut Self, String>
pub fn try_set_key_field(&mut self, name: &str) -> Result<&mut Self, String>
Try to set the key field by name, returning an error if the field is not found
Sourcepub fn record_size(&self) -> usize
pub fn record_size(&self) -> usize
Calculate the total size of a record in bytes
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Schema
impl RefUnwindSafe for Schema
impl Send for Schema
impl Sync for Schema
impl Unpin for Schema
impl UnwindSafe for Schema
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more