Skip to content

Commit

Permalink
Introduce DataNodeRef::typedef_name()
Browse files Browse the repository at this point in the history
Signed-off-by: Renato Westphal <[email protected]>
  • Loading branch information
rwestphal committed May 14, 2024
1 parent dfc3fa6 commit b3fe671
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,23 @@ impl<'a> SchemaNode<'a> {
Some(DataValueType::from_u32(ltype).unwrap())
}

/// Referenced typedef name of the leaf(-list).
pub fn typedef_name(&self) -> Option<String> {
let ltype = unsafe {
match self.kind() {
SchemaNodeKind::Leaf => {
(*(self.raw as *mut ffi::lysc_node_leaf)).type_
}
SchemaNodeKind::LeafList => {
(*(self.raw as *mut ffi::lysc_node_leaflist)).type_
}
_ => return None,
}
};
let ltypedef = unsafe { (*ltype).name };
char_ptr_to_opt_string(ltypedef)
}

/// Units of the leaf(-list)'s type.
pub fn units(&self) -> Option<&str> {
let units = unsafe {
Expand Down

0 comments on commit b3fe671

Please sign in to comment.