#[repr(transparent)]pub struct Node { /* private fields */ }
Expand description
Struct that represents the underlying fdt_node
(Flattened device tree).
Implementations§
source§impl Node
impl Node
pub fn child(&mut self, child: NodeBuf) -> &mut Self
pub fn has_prop(&self, name: impl AsRef<CStr>) -> bool
pub fn prop<Prop: FdtNodeAddPropExt>(
&mut self,
name: impl AsRef<CStr>,
prop: Prop
) -> &mut Self
sourcepub fn find_mut<By: FdtFindExt>(&mut self, by: By) -> Option<&mut Node>
pub fn find_mut<By: FdtFindExt>(&mut self, by: By) -> Option<&mut Node>
Search node in the tree. See Node::find
.
sourcepub fn find<By: FdtFindExt>(&self, by: By) -> Option<&Node>
pub fn find<By: FdtFindExt>(&self, by: By) -> Option<&Node>
Search through the node tree.
Supported filters:
- by name search, takes Name(cstr) struct
- by name search, takes any
AsRef<str>
struct, but allocates newCString
and can panic if passed string contains nul-byte terminator - search by name and region (searches the region node type), takes Region(cstr, region).
- search by name (searches the region node type), takes AnyRegion(cstr)
sourcepub fn serialize(&self, boot_cpuid: u32) -> Vec<u8>
pub fn serialize(&self, boot_cpuid: u32) -> Vec<u8>
Serializes nodes to the dynamically allocated buffer.
Same as calling to Node::size
and then
Node::try_serialize_to_uninit
with the
pre-allocated buffer with sufficient size.
Refer to the Node::try_serialize_to_uninit
for
more information.
sourcepub fn try_serialize_to<'a>(
&self,
to: &'a mut [u8],
boot_cpuid: u32
) -> Result<usize, SerializeError>
pub fn try_serialize_to<'a>(
&self,
to: &'a mut [u8],
boot_cpuid: u32
) -> Result<usize, SerializeError>
Try serialize to buffer. Same as
Node::try_serialize_to_uninit
but consumes the
initialized slice of bytes, refer to the
Node::try_serialize_to_uninit
for more detailed
description.
sourcepub fn try_serialize_to_uninit(
&self,
to: &mut [MaybeUninit<u8>],
boot_cpuid: u32
) -> Result<usize, SerializeError>
pub fn try_serialize_to_uninit(
&self,
to: &mut [MaybeUninit<u8>],
boot_cpuid: u32
) -> Result<usize, SerializeError>
Try serialize to buffer.
Returns Ok
with size of serialized content,
otherwise Err
with the SerializeError
enum.
source§impl Node
impl Node
sourcepub fn name<'a>(&'a self) -> Option<&'a CStr>
pub fn name<'a>(&'a self) -> Option<&'a CStr>
Get Node name. Returns None if node has no name.
use rvvm::fdt::*;
let node1 = NodeBuf::new("Nero");
let node2 = NodeBuf::new(None);
let node3 = NodeBuf::root();
assert_eq!(node1.name().unwrap().to_str().unwrap(), "Nero");
assert!(node2.name().is_none());
assert!(node3.name().is_none());
source§impl Node
impl Node
sourcepub unsafe fn from_ptr<'new>(ptr: *const fdt_node) -> &'new Node
pub unsafe fn from_ptr<'new>(ptr: *const fdt_node) -> &'new Node
Creates Node
reference from the underlying pointer
to the fdt_node
.
Safety
This function is unsafe due to lack of pointer validity checks and due to possibility of producing an unbounded lifetimes, so actions considered UB are:
- Specifying an invalid aligned pointer or null pointer
- Specifying invalid pointer to the
fdt_node
struct
Not considered as UB, but possible logical errors:
- Producing an unbounded lifetime. Explicit lifetime specifying is heavily reccommended, since lifetime can be anything that satisfies the type-inference.