Struct cros_fdt::fdt::FdtNode

source ·
pub struct FdtNode {
    pub(crate) name: String,
    pub(crate) props: IndexMap<String, Vec<u8>>,
    pub(crate) subnodes: IndexMap<String, FdtNode>,
}
Expand description

Flattened device tree node.

This represents a single node from the FDT structure block. Every node may contain properties and other (child) nodes.

Fields§

§name: String

Node name

§props: IndexMap<String, Vec<u8>>§subnodes: IndexMap<String, FdtNode>

Implementations§

source§

impl FdtNode

source

pub(crate) fn new( name: String, props: IndexMap<String, Vec<u8>>, subnodes: IndexMap<String, FdtNode> ) -> Result<Self>

source

pub(crate) fn empty(name: impl Into<String>) -> Result<Self>

source

fn read_token(input: &mut &'_ [u8]) -> Result<u32>

source

fn parse_node(input: &mut &'_ [u8], strings: &FdtStrings) -> Result<Self>

source

fn from_blob(input: &'_ [u8], strings: &FdtStrings) -> Result<Self>

source

fn write_blob( &self, writer: &mut impl Write, strings: &mut FdtStrings ) -> Result<()>

source

pub(crate) fn prop_names(&self) -> impl Iterator<Item = &str>

source

pub(crate) fn has_prop(&self, name: &str) -> bool

source

pub fn get_prop<T>(&self, name: &str) -> Option<T>
where T: FromFdtPropval,

Read property value if it exists.

§Arguments

name - name of the property.

source

pub(crate) fn phandle_at_offset(&self, name: &str, offset: usize) -> Option<u32>

source

pub(crate) fn update_phandle_at_offset( &mut self, name: &str, offset: usize, phandle: u32 ) -> Result<()>

source

pub fn set_prop<T>(&mut self, name: &str, value: T) -> Result<()>
where T: ToFdtPropval,

Write a property.

§Arguments

name - name of the property; must be a valid property name according to DT spec. val - value of the property (raw byte array).

source

pub fn subnode(&self, name: &str) -> Option<&FdtNode>

Return a reference to an existing subnode with given name, or None if it doesn’t exist.

§Arguments

name - name of the node.

source

pub fn subnode_mut(&mut self, name: &str) -> Result<&mut FdtNode>

Create a node if it doesn’t already exist, and return a mutable reference to it. Return an error if the node name is not valid.

§Arguments

name - name of the node; must be a valid node name according to DT specification.

source

pub(crate) fn iter_subnodes(&self) -> impl Iterator<Item = &FdtNode>

source

pub(crate) fn iter_subnodes_mut(&mut self) -> impl Iterator<Item = &mut FdtNode>

Trait Implementations§

source§

impl Clone for FdtNode

source§

fn clone(&self) -> FdtNode

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for FdtNode

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.