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>
impl<'b, 'a: 'b> Root<'b, 'a>
Sourcepub fn cell_sizes(self) -> CellSizes
pub fn cell_sizes(self) -> CellSizes
Root node cell sizes
Sourcepub fn model(self) -> &'a str
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}
Sourcepub fn compatible(self) -> Compatible<'a>
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}
Sourcepub fn properties(self) -> impl Iterator<Item = NodeProperty<'a>> + 'b
pub fn properties(self) -> impl Iterator<Item = NodeProperty<'a>> + 'b
Returns an iterator over all of the available properties
Sourcepub fn property(self, name: &str) -> Option<NodeProperty<'a>>
pub fn property(self, name: &str) -> Option<NodeProperty<'a>>
Attempts to find the a property by its name
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more