pub struct Tree<'a, E: Elem + Into<u32>, C: Component> {
pub buf: &'a [E],
pub component: &'a C,
}Expand description
Represents a section of a component tree that’s present in a buffer.
Fields§
§buf: &'a [E]§component: &'a CImplementations§
Source§impl<'a, E: Elem + Into<u32>, C: Component> Tree<'a, E, C>
impl<'a, E: Elem + Into<u32>, C: Component> Tree<'a, E, C>
Sourcepub fn new(buf: &'a [E], component: &'a C) -> Self
pub fn new(buf: &'a [E], component: &'a C) -> Self
Returns the component tree rooted at the given component.
Sourcepub fn map<SUBC: Component>(
&self,
f: impl FnOnce(&'a C) -> &'a SUBC,
) -> Tree<'a, E, SUBC>
pub fn map<SUBC: Component>( &self, f: impl FnOnce(&'a C) -> &'a SUBC, ) -> Tree<'a, E, SUBC>
Descends into a subtree. The given function should return the requested layout based when passed this tree’s layout.
Sourcepub fn get_u32s(&self) -> Result<Vec<u32>>
pub fn get_u32s(&self) -> Result<Vec<u32>>
Interprets the contents of this tree as a list of u32s.
Sourcepub fn get_bytes(&self) -> Result<Vec<u8>>
pub fn get_bytes(&self) -> Result<Vec<u8>>
Interprets the contents of this tree as a list of bytes.
Sourcepub fn get_shorts(&self) -> Result<Vec<u16>>
pub fn get_shorts(&self) -> Result<Vec<u16>>
Interprets the contents of this tree as a list of shorts.
Sourcepub fn get_digest_from_shorts(&self) -> Result<Digest>
pub fn get_digest_from_shorts(&self) -> Result<Digest>
Interprets the contents of this tree as a digest based on a list of shorts.
Sourcepub fn get_u32_from_bytes(&self) -> Result<u32>
pub fn get_u32_from_bytes(&self) -> Result<u32>
Returns the contents of this tree as a u32; elements are expected to be 4 bytes.
Sourcepub fn get_u32_from_elem(&self) -> Result<u32>
pub fn get_u32_from_elem(&self) -> Result<u32>
Returns the contents of this tree, which should have a single element, as a u32.
Trait Implementations§
impl<'a, E: Copy + Elem + Into<u32>, C: Copy + Component> Copy for Tree<'a, E, C>
Auto Trait Implementations§
impl<'a, E, C> Freeze for Tree<'a, E, C>
impl<'a, E, C> RefUnwindSafe for Tree<'a, E, C>where
C: RefUnwindSafe,
E: RefUnwindSafe,
impl<'a, E, C> Send for Tree<'a, E, C>where
C: Sync,
impl<'a, E, C> Sync for Tree<'a, E, C>where
C: Sync,
impl<'a, E, C> Unpin for Tree<'a, E, C>
impl<'a, E, C> UnwindSafe for Tree<'a, E, C>where
C: RefUnwindSafe,
E: RefUnwindSafe,
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