pub struct NodeInfo {
pub type_name: String,
pub id: String,
pub fields: Vec<Value>,
pub depth: usize,
pub parent_id: Option<String>,
pub parent_type: Option<String>,
pub line: usize,
}Expand description
Information about a parsed node (entity/row).
Represents a single entity parsed from a HEDL matrix row. Contains the entity’s type, ID, field values, and parent relationship information.
§Field Access
Fields can be accessed by index using get_field().
The first field (index 0) is always the ID.
§Examples
§Accessing Fields
use hedl_stream::{StreamingParser, NodeEvent};
use hedl_core::Value;
use std::io::Cursor;
let input = r#"
%VERSION: 1.0
%STRUCT: User: [id, name, email, active]
---
users: @User
| alice, Alice Smith, alice@example.com, true
"#;
let parser = StreamingParser::new(Cursor::new(input))?;
for event in parser {
if let Ok(NodeEvent::Node(node)) = event {
// Access by index
assert_eq!(node.get_field(0), Some(&Value::String("alice".to_string())));
assert_eq!(node.get_field(1), Some(&Value::String("Alice Smith".to_string())));
assert_eq!(node.get_field(3), Some(&Value::Bool(true)));
// Or use the id field directly
assert_eq!(node.id, "alice");
}
}§Checking Parent Relationships
use hedl_stream::{StreamingParser, NodeEvent};
use std::io::Cursor;
let input = r#"
%VERSION: 1.0
%STRUCT: User: [id, name]
%STRUCT: Order: [id, amount]
%NEST: User > Order
---
users: @User
| alice, Alice
| order1, 100.00
"#;
let parser = StreamingParser::new(Cursor::new(input))?;
for event in parser.filter_map(|e| e.ok()) {
if let NodeEvent::Node(node) = event {
if node.is_nested() {
println!("{} is a child of {:?}",
node.id, node.parent_id.as_ref().unwrap());
}
}
}Fields§
§type_name: StringThe entity type name.
id: StringThe entity ID.
fields: Vec<Value>Field values aligned with schema.
depth: usizeNesting depth (0 = top-level).
parent_id: Option<String>Parent node ID (if nested).
parent_type: Option<String>Parent type name (if nested).
line: usizeLine number in source.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for NodeInfo
impl RefUnwindSafe for NodeInfo
impl Send for NodeInfo
impl Sync for NodeInfo
impl Unpin for NodeInfo
impl UnwindSafe for NodeInfo
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