Struct Root

Source
pub struct Root<'b, 'a: 'b> { /* private fields */ }
Expand description

Represents the root (/) node with specific helper methods

Implementations§

Source§

impl<'b, 'a: 'b> Root<'b, 'a>

Source

pub fn cell_sizes(self) -> CellSizes

Root node cell sizes

Source

pub fn model(self) -> &'a str

model property

Examples found in repository?
examples/basic_info.rs (line 8)
5fn main() {
6    let fdt = fdt::Fdt::new(MY_FDT).unwrap();
7
8    println!("This is a devicetree representation of a {}", fdt.root().unwrap().model());
9    println!(
10        "...which is compatible with at least: {}",
11        fdt.root().unwrap().compatible().first().unwrap()
12    );
13    println!("...and has {} CPU(s)", fdt.cpus().count());
14    println!(
15        "...and has at least one memory location at: {:#X}\n",
16        fdt.memory().unwrap().regions().next().unwrap().starting_address as usize
17    );
18
19    let chosen = fdt.chosen().unwrap();
20    if let Some(bootargs) = chosen.bootargs() {
21        println!("The bootargs are: {:?}", bootargs);
22    }
23
24    if let Some(stdout) = chosen.stdout() {
25        println!(
26            "It would write stdout to: {} with params: {:?}",
27            stdout.node().name,
28            stdout.params()
29        );
30    }
31
32    let soc = fdt.find_node("/soc");
33    println!("Does it have a `/soc` node? {}", if soc.is_some() { "yes" } else { "no" });
34    if let Some(soc) = soc {
35        println!("...and it has the following children:");
36        for child in soc.children() {
37            println!("    {}", child.name);
38        }
39    }
40}
Source

pub fn compatible(self) -> Compatible<'a>

compatible property

Examples found in repository?
examples/basic_info.rs (line 11)
5fn main() {
6    let fdt = fdt::Fdt::new(MY_FDT).unwrap();
7
8    println!("This is a devicetree representation of a {}", fdt.root().unwrap().model());
9    println!(
10        "...which is compatible with at least: {}",
11        fdt.root().unwrap().compatible().first().unwrap()
12    );
13    println!("...and has {} CPU(s)", fdt.cpus().count());
14    println!(
15        "...and has at least one memory location at: {:#X}\n",
16        fdt.memory().unwrap().regions().next().unwrap().starting_address as usize
17    );
18
19    let chosen = fdt.chosen().unwrap();
20    if let Some(bootargs) = chosen.bootargs() {
21        println!("The bootargs are: {:?}", bootargs);
22    }
23
24    if let Some(stdout) = chosen.stdout() {
25        println!(
26            "It would write stdout to: {} with params: {:?}",
27            stdout.node().name,
28            stdout.params()
29        );
30    }
31
32    let soc = fdt.find_node("/soc");
33    println!("Does it have a `/soc` node? {}", if soc.is_some() { "yes" } else { "no" });
34    if let Some(soc) = soc {
35        println!("...and it has the following children:");
36        for child in soc.children() {
37            println!("    {}", child.name);
38        }
39    }
40}
Source

pub fn properties(self) -> impl Iterator<Item = NodeProperty<'a>> + 'b

Returns an iterator over all of the available properties

Source

pub fn property(self, name: &str) -> Option<NodeProperty<'a>>

Attempts to find the a property by its name

Trait Implementations§

Source§

impl<'b, 'a: 'b> Clone for Root<'b, 'a>

Source§

fn clone(&self) -> Root<'b, 'a>

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<'b, 'a: 'b> Debug for Root<'b, 'a>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'b, 'a: 'b> Copy for Root<'b, 'a>

Auto Trait Implementations§

§

impl<'b, 'a> Freeze for Root<'b, 'a>

§

impl<'b, 'a> RefUnwindSafe for Root<'b, 'a>

§

impl<'b, 'a> Send for Root<'b, 'a>

§

impl<'b, 'a> Sync for Root<'b, 'a>

§

impl<'b, 'a> Unpin for Root<'b, 'a>

§

impl<'b, 'a> UnwindSafe for Root<'b, 'a>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.