pub struct Tree<'a> { /* private fields */ }
Expand description
Represents a full flattened device tree blob (DTB).
Implementations§
Source§impl<'a> Tree<'a>
impl<'a> Tree<'a>
Sourcepub unsafe fn from_ptr<E: ParseError<&'a [u8]>>(
ptr: *const u8,
) -> Result<Self, Err<E>>
pub unsafe fn from_ptr<E: ParseError<&'a [u8]>>( ptr: *const u8, ) -> Result<Self, Err<E>>
Parse a devicetree blob that begins at the specified memory address.
§Safety
The pointer must hold the address of the first byte of a valid devicetree blob,
and it must uphold all the invariants of core::slice::from_raw_parts
for a
slice beginning at the specified address and extending the total length of the DTB
as given in its header.
§Errors
If the header does not have the correct magic number, or any other properties of the header are invalid, this function will return an error.
Sourcepub fn from_buffer<E: ParseError<&'a [u8]>>(
data: &'a [u8],
) -> Result<Self, Err<E>>
pub fn from_buffer<E: ParseError<&'a [u8]>>( data: &'a [u8], ) -> Result<Self, Err<E>>
Parse a devicetree blob that starts at the beginning of the slice and extends no further than its end.
§Errors
If the header does not have the correct magic number, or any other properties of the header are invalid, this function will return an error.
Sourcepub fn memory_reservation_iter<E: ParseError<&'a [u8]> + 'a>(
self: &'a Tree<'a>,
) -> impl Iterator<Item = Result<MemoryReservation, Err<E>>> + 'a
pub fn memory_reservation_iter<E: ParseError<&'a [u8]> + 'a>( self: &'a Tree<'a>, ) -> impl Iterator<Item = Result<MemoryReservation, Err<E>>> + 'a
Iterate over memory reservations defined by this devicetree
Sourcepub fn structure_iter<E: GeneralParseError<&'a [u8]>>(
self: &'a Tree<'a>,
) -> impl Iterator<Item = Result<StructureData<'a>, Err<E>>>
pub fn structure_iter<E: GeneralParseError<&'a [u8]>>( self: &'a Tree<'a>, ) -> impl Iterator<Item = Result<StructureData<'a>, Err<E>>>
Iterate over elements in the device tree. Note that this does not directly iterate over nodes, but rather events that indicate the start of a node (including its children), a property defined on the node, or the end of a node.