Struct rvvm::fdt::Node

source ·
#[repr(transparent)]
pub struct Node { /* private fields */ }
Expand description

Struct that represents the underlying fdt_node (Flattened device tree).

Implementations§

Search node in the tree. See Node::find.

Search through the node tree.

Supported filters:

  • by name search, takes Name(cstr) struct
  • by name search, takes any AsRef<str> struct, but allocates new CString 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)

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.

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.

Try serialize to buffer.

Returns Ok with size of serialized content, otherwise Err with the SerializeError enum.

Calculate size of the serialized fdt

Creates Node from the fdt_node type.

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());

Check whether node is root or not.

use rvvm::fdt::*;

let node1 = NodeBuf::new("LekKit");
let node2 = NodeBuf::root();
let node3 = NodeBuf::new(None);

assert!(!node1.is_root());
assert!(node2.is_root());
assert!(node3.is_root());

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.

Creates mutable Node from the underlying pointer.

Safety

Same as the Node::from_ptr

Trait Implementations§

Converts this type into a mutable reference of the (usually inferred) input type.
Converts this type into a shared reference of the (usually inferred) input type.
Converts to this type from the input type.
Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.