fdt_parser/
chosen.rs

1use crate::node::Node;
2
3pub struct Chosen<'a> {
4    node: Node<'a>,
5}
6
7impl<'a> Chosen<'a> {
8    pub fn new(node: Node<'a>) -> Self {
9        Chosen { node }
10    }
11
12    /// Contains the bootargs, if they exist
13    pub fn bootargs(&self) -> Option<&'a str> {
14        self.node.find_property("bootargs").map(|p| p.str())
15    }
16
17    /// Searches for the node representing `stdout`, if the property exists,
18    /// attempting to resolve aliases if the node name doesn't exist as-is
19    pub fn stdout(&self) -> Option<Stdout<'a>> {
20        let path = self.node.find_property("stdout-path")?.str();
21        let mut sp = path.split(':');
22        let name = sp.next()?;
23        let params = sp.next();
24        let node = self.node.fdt.find_nodes(name).next()?;
25        Some(Stdout { params, node })
26    }
27}
28
29pub struct Stdout<'a> {
30    pub params: Option<&'a str>,
31    pub node: Node<'a>,
32}