pub struct AccountTree<'arena> { /* private fields */ }Expand description
Represents the tree structure of the accounts, stored in the [AccountStore].
Implementations§
Source§impl<'arena> AccountTree<'arena>
impl<'arena> AccountTree<'arena>
Sourcepub fn new(arena: &'arena Bump) -> Self
pub fn new(arena: &'arena Bump) -> Self
Creates a new instance.
This constructs only a plain empty tree, and the actual work is done
in Self::construct() because we want to retain the prefixes
lifetime aligned with [AccountStore].
Sourcepub fn construct(&mut self, accounts: &AccountStore<'arena>)
pub fn construct(&mut self, accounts: &AccountStore<'arena>)
Constructs the tree state from the given [AccountStore].
Sourcepub fn resolve_ancestor(&self, label: &str) -> Option<AccountAncestor<'arena>>
pub fn resolve_ancestor(&self, label: &str) -> Option<AccountAncestor<'arena>>
Resolves the [AccountAncestor] corresponding to the given label.
Returns None if not found.
Note that this would also return None if the given label is Account.
See super::ReportContext::account_aggregate(), that is more convenient.
Sourcepub fn parent<T: Into<AccountAggregate<'arena>>>(
&self,
account: T,
) -> Option<AccountTreeKey<'arena>>
pub fn parent<T: Into<AccountAggregate<'arena>>>( &self, account: T, ) -> Option<AccountTreeKey<'arena>>
Returns the parent of the given node.
None if the given account is not found in the tree.
Sourcepub fn children<T: Into<AccountTreeKey<'arena>>>(
&self,
key: T,
) -> Option<&[AccountAggregate<'arena>]>
pub fn children<T: Into<AccountTreeKey<'arena>>>( &self, key: T, ) -> Option<&[AccountAggregate<'arena>]>
Returns the children of the given node.
None if the given key is not found,
and empty slice for the leaf account.