pub struct BpsvSchema { /* private fields */ }
Expand description
Represents the complete schema of a BPSV document
Implementations§
Source§impl BpsvSchema
impl BpsvSchema
Sourcepub fn parse_header(header_line: &str) -> Result<Self>
pub fn parse_header(header_line: &str) -> Result<Self>
Parse schema from a header line
§Examples
use ngdp_bpsv::BpsvSchema;
let header = "Region!STRING:0|BuildConfig!HEX:16|BuildId!DEC:4";
let schema = BpsvSchema::parse_header(header)?;
assert_eq!(schema.field_count(), 3);
assert!(schema.has_field("Region"));
assert!(schema.has_field("BuildConfig"));
assert!(schema.has_field("BuildId"));
Sourcepub fn add_field(
&mut self,
name: String,
field_type: BpsvFieldType,
) -> Result<()>
pub fn add_field( &mut self, name: String, field_type: BpsvFieldType, ) -> Result<()>
Add a field to the schema
Sourcepub fn field_count(&self) -> usize
pub fn field_count(&self) -> usize
Get the number of fields
Sourcepub fn get_field_by_index(&self, index: usize) -> Option<&BpsvField>
pub fn get_field_by_index(&self, index: usize) -> Option<&BpsvField>
Get a field by index
Sourcepub fn field_names(&self) -> Vec<&str>
pub fn field_names(&self) -> Vec<&str>
Get field names in order
Sourcepub fn validate_row(&self, values: &[String]) -> Result<Vec<String>>
pub fn validate_row(&self, values: &[String]) -> Result<Vec<String>>
Validate a row of values against this schema
Sourcepub fn validate_row_refs<'a>(&self, values: &[&'a str]) -> Result<Vec<&'a str>>
pub fn validate_row_refs<'a>(&self, values: &[&'a str]) -> Result<Vec<&'a str>>
Validate a row of string references against this schema (zero-copy)
Sourcepub fn to_header_line(&self) -> String
pub fn to_header_line(&self) -> String
Generate the header line for this schema
Trait Implementations§
Source§impl Clone for BpsvSchema
impl Clone for BpsvSchema
Source§fn clone(&self) -> BpsvSchema
fn clone(&self) -> BpsvSchema
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for BpsvSchema
impl Debug for BpsvSchema
Source§impl Default for BpsvSchema
impl Default for BpsvSchema
Source§impl PartialEq for BpsvSchema
impl PartialEq for BpsvSchema
impl StructuralPartialEq for BpsvSchema
Auto Trait Implementations§
impl Freeze for BpsvSchema
impl RefUnwindSafe for BpsvSchema
impl Send for BpsvSchema
impl Sync for BpsvSchema
impl Unpin for BpsvSchema
impl UnwindSafe for BpsvSchema
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