pub struct Tree { /* private fields */ }Implementations§
Source§impl Tree
impl Tree
pub fn new(caps: Caps) -> Tree
pub fn caps(&self) -> Caps
pub fn is_draining(&self) -> bool
pub fn total_tokens(&self) -> u64
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn get(&self, id: NodeId) -> Option<&Node>
pub fn root(&self) -> Option<NodeId>
Sourcepub fn mint_root(&mut self) -> Result<NodeId, SpawnRefused>
pub fn mint_root(&mut self) -> Result<NodeId, SpawnRefused>
Mint the root node (depth 0, path 0). The one-shot/loop root agent.
Sourcepub fn mint_child(&mut self, parent: NodeId) -> Result<NodeId, SpawnRefused>
pub fn mint_child(&mut self, parent: NodeId) -> Result<NodeId, SpawnRefused>
Mint a child of parent, enforcing every cap. Depth and path are
derived from the parent here — this is the single chokepoint, so no
caller can bypass a cap by supplying its own depth. The caller then
attaches the OS handle to the returned node.
pub fn set_status(&mut self, id: NodeId, status: NodeStatus)
Sourcepub fn charge_tokens(&mut self, id: NodeId, tokens: u64) -> bool
pub fn charge_tokens(&mut self, id: NodeId, tokens: u64) -> bool
Charge tokens to a node and the tree root. Returns true if the tree-wide ceiling is now exceeded (caller drains the tree).
Sourcepub fn set_draining(&mut self)
pub fn set_draining(&mut self)
Flip the one-way draining flag (SIGTERM / tree-budget breach). After
this, mint_* refuses, so a parent cannot spawn replacements mid-teardown
and the kill ladder always terminates.
Sourcepub fn deepest_first(&self) -> Vec<NodeId>
pub fn deepest_first(&self) -> Vec<NodeId>
Node ids ordered deepest-first — the kill-ladder teardown order. Children must die before parents, otherwise a killed parent’s children are reparented to pid 1 and escape the tree’s accounting entirely.