pub struct BpsvDocument<'a> { /* private fields */ }
Expand description
Represents a complete BPSV document with borrowed data
Implementations§
Source§impl<'a> BpsvDocument<'a>
impl<'a> BpsvDocument<'a>
Sourcepub fn new(content: &'a str, schema: BpsvSchema) -> Self
pub fn new(content: &'a str, schema: BpsvSchema) -> Self
Create a new BPSV document
Sourcepub fn parse(content: &'a str) -> Result<Self>
pub fn parse(content: &'a str) -> Result<Self>
Parse a BPSV document from string content
§Examples
use ngdp_bpsv::BpsvDocument;
let content = "Region!STRING:0|BuildId!DEC:4\n## seqn = 12345\nus|1234\neu|5678";
let doc = BpsvDocument::parse(content)?;
assert_eq!(doc.sequence_number(), Some(12345));
assert_eq!(doc.rows().len(), 2);
Sourcepub fn schema(&self) -> &BpsvSchema
pub fn schema(&self) -> &BpsvSchema
Get the schema
Sourcepub fn sequence_number(&self) -> Option<u32>
pub fn sequence_number(&self) -> Option<u32>
Get the sequence number
Sourcepub fn set_sequence_number(&mut self, seqn: Option<u32>)
pub fn set_sequence_number(&mut self, seqn: Option<u32>)
Set the sequence number
Sourcepub fn add_typed_row(&mut self, values: Vec<BpsvValue>) -> Result<()>
pub fn add_typed_row(&mut self, values: Vec<BpsvValue>) -> Result<()>
Add a row from typed values
Sourcepub fn get_row_mut(&mut self, index: usize) -> Option<&mut BpsvRow<'a>>
pub fn get_row_mut(&mut self, index: usize) -> Option<&mut BpsvRow<'a>>
Get a mutable row by index
Sourcepub fn find_rows_by_field(
&self,
field_name: &str,
value: &str,
) -> Result<Vec<usize>>
pub fn find_rows_by_field( &self, field_name: &str, value: &str, ) -> Result<Vec<usize>>
Find rows where a field matches a specific value
Sourcepub fn to_bpsv_string(&self) -> String
pub fn to_bpsv_string(&self) -> String
Convert the entire document back to BPSV format
Sourcepub fn get_column(&self, field_name: &str) -> Result<Vec<&str>>
pub fn get_column(&self, field_name: &str) -> Result<Vec<&str>>
Get all values for a specific field
Sourcepub fn to_maps(&self) -> Result<Vec<HashMap<String, String>>>
pub fn to_maps(&self) -> Result<Vec<HashMap<String, String>>>
Convert all rows to maps for easier access
Sourcepub fn into_owned_rows(self) -> Vec<OwnedBpsvRow>
pub fn into_owned_rows(self) -> Vec<OwnedBpsvRow>
Convert to owned rows for interning
Trait Implementations§
Source§impl<'a> Clone for BpsvDocument<'a>
impl<'a> Clone for BpsvDocument<'a>
Source§fn clone(&self) -> BpsvDocument<'a>
fn clone(&self) -> BpsvDocument<'a>
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<'a> Debug for BpsvDocument<'a>
impl<'a> Debug for BpsvDocument<'a>
Source§impl<'a> PartialEq for BpsvDocument<'a>
impl<'a> PartialEq for BpsvDocument<'a>
impl<'a> StructuralPartialEq for BpsvDocument<'a>
Auto Trait Implementations§
impl<'a> Freeze for BpsvDocument<'a>
impl<'a> RefUnwindSafe for BpsvDocument<'a>
impl<'a> Send for BpsvDocument<'a>
impl<'a> Sync for BpsvDocument<'a>
impl<'a> Unpin for BpsvDocument<'a>
impl<'a> UnwindSafe for BpsvDocument<'a>
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