fdt_parser/
property.rs

1use core::ffi::CStr;
2
3use crate::read::FdtReader;
4
5#[derive(Clone)]
6pub struct Property<'a> {
7    pub name: &'a str,
8    pub(crate) data: FdtReader<'a>,
9}
10
11impl<'a> Property<'a> {
12    pub fn raw_value(&self) -> &'a [u8] {
13        self.data.remaining()
14    }
15
16    pub fn u32(&self) -> u32 {
17        self.data.clone().take_u32().unwrap()
18    }
19
20    pub fn u64(&self) -> u64 {
21        self.data.clone().take_u64().unwrap()
22    }
23
24    pub fn str(&self) -> &'a str {
25        CStr::from_bytes_until_nul(self.data.remaining())
26            .unwrap()
27            .to_str()
28            .unwrap()
29    }
30}