pub struct HeaderInfo {
pub version: (u32, u32),
pub structs: BTreeMap<String, Vec<String>>,
pub aliases: BTreeMap<String, String>,
pub nests: BTreeMap<String, Vec<String>>,
pub null_char: char,
pub quote_char: char,
pub count_totals: BTreeMap<String, usize>,
pub count_fields: BTreeMap<String, BTreeMap<String, usize>>,
}Expand description
Header information parsed from the HEDL document.
Contains metadata extracted from header directives:
%VERSION: Document format version%STRUCT: Schema definitions mapping type names to column lists%ALIAS: Variable substitutions%NEST: Parent-child relationship rules
§Examples
use hedl_stream::{StreamingParser, HeaderInfo};
use std::io::Cursor;
let input = r#"
%VERSION: 1.0
%STRUCT: User: [id, name, email]
%ALIAS: admin = "Administrator"
%NEST: User > Order
---
"#;
let parser = StreamingParser::new(Cursor::new(input))?;
let header = parser.header().unwrap();
// Access version
let (major, minor) = header.version;
println!("HEDL version {}.{}", major, minor);
// Look up schema
if let Some(schema) = header.get_schema("User") {
println!("User has {} fields", schema.len());
}
// Check for alias
if let Some(value) = header.aliases.get("admin") {
println!("Alias 'admin' expands to '{}'", value);
}
// Check nesting rule
if let Some(children) = header.get_child_types("User") {
println!("User can contain {:?}", children);
}Fields§
§version: (u32, u32)HEDL version (major, minor).
structs: BTreeMap<String, Vec<String>>Schema definitions: type -> columns.
aliases: BTreeMap<String, String>Alias definitions.
nests: BTreeMap<String, Vec<String>>Nest relationships: parent -> children. A parent type can have multiple child types.
null_char: charNull literal character (v2.0+). Default: ‘~’.
quote_char: charQuote character (v2.0+). Default: ‘“’.
count_totals: BTreeMap<String, usize>Count hints: Type.total -> count (v2.0+).
count_fields: BTreeMap<String, BTreeMap<String, usize>>Count hints: Type.field:value -> count (v2.0+).
Implementations§
Source§impl HeaderInfo
impl HeaderInfo
Trait Implementations§
Source§impl Clone for HeaderInfo
impl Clone for HeaderInfo
Source§fn clone(&self) -> HeaderInfo
fn clone(&self) -> HeaderInfo
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 HeaderInfo
impl Debug for HeaderInfo
Auto Trait Implementations§
impl Freeze for HeaderInfo
impl RefUnwindSafe for HeaderInfo
impl Send for HeaderInfo
impl Sync for HeaderInfo
impl Unpin for HeaderInfo
impl UnwindSafe for HeaderInfo
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