pub struct ProcessTree { /* private fields */ }Expand description
A process tree flattened into display order.
Implementations§
Source§impl ProcessTree
impl ProcessTree
Sourcepub fn from_snapshot(snapshot: &SystemSnapshot, sort: ProcessSort) -> Self
pub fn from_snapshot(snapshot: &SystemSnapshot, sort: ProcessSort) -> Self
Builds the tree of every process in snapshot.
Sourcepub fn from_snapshot_filtered(
snapshot: &SystemSnapshot,
sort: ProcessSort,
filter: &ProcessFilter,
) -> Self
pub fn from_snapshot_filtered( snapshot: &SystemSnapshot, sort: ProcessSort, filter: &ProcessFilter, ) -> Self
Builds the tree of the processes in snapshot that pass filter.
Sourcepub fn build<P: Borrow<ProcessSnapshot>>(
processes: &[P],
sort: ProcessSort,
) -> Self
pub fn build<P: Borrow<ProcessSnapshot>>( processes: &[P], sort: ProcessSort, ) -> Self
Builds the tree of every process in processes.
Sourcepub fn build_filtered<P: Borrow<ProcessSnapshot>>(
processes: &[P],
sort: ProcessSort,
filter: &ProcessFilter,
) -> Self
pub fn build_filtered<P: Borrow<ProcessSnapshot>>( processes: &[P], sort: ProcessSort, filter: &ProcessFilter, ) -> Self
Builds the tree of the processes that pass filter.
A hidden process does not orphan its children: they re-attach to the nearest surviving ancestor, so hiding kernel threads or filtering by name reshapes the tree without scattering unrelated rows to the root. Rows that do not pass the filter simply do not appear.
Sourcepub fn row_of(&self, identity: ProcessIdentity) -> Option<usize>
pub fn row_of(&self, identity: ProcessIdentity) -> Option<usize>
The row showing identity, if it is in the tree.
Keyed on the full identity, so a reused PID resolves to nothing rather than to the wrong row (§26).
Sourcepub const fn cycles_broken(&self) -> u32
pub const fn cycles_broken(&self) -> u32
How many parent links were cut to break a cycle, self-parents included.
Zero on any sane system. A non-zero value is worth surfacing as collector health rather than hiding, because it means the process table was read while the graph was inconsistent.
Sourcepub fn subtree_len(&self, index: usize) -> usize
pub fn subtree_len(&self, index: usize) -> usize
The number of rows this row occupies together with its subtree.
Sourcepub fn child_rows(&self, index: usize) -> Vec<usize>
pub fn child_rows(&self, index: usize) -> Vec<usize>
The direct children of a row, in display order (§2.4 child navigation).
Sourcepub fn ancestor_rows(&self, index: usize) -> Vec<usize>
pub fn ancestor_rows(&self, index: usize) -> Vec<usize>
The ancestors of a row, nearest parent first (§2.4 breadcrumb).
Terminates because parent_row is always a smaller index than the row it
belongs to: pre-order emission guarantees it, so the walk strictly
decreases.
Sourcepub fn continuation_flags(&self, index: usize) -> Vec<bool>
pub fn continuation_flags(&self, index: usize) -> Vec<bool>
Whether a vertical continuation line is needed at each level above a row.
Element i covers indentation level i (root-most first) and is true
when the ancestor at that level still has siblings below it, so the renderer
draws | there and three spaces otherwise. The row’s own connector comes
from TreeRow::is_last_child.
Sourcepub fn process<'a, P: Borrow<ProcessSnapshot>>(
&self,
processes: &'a [P],
index: usize,
) -> Option<&'a ProcessSnapshot>
pub fn process<'a, P: Borrow<ProcessSnapshot>>( &self, processes: &'a [P], index: usize, ) -> Option<&'a ProcessSnapshot>
The process a row refers to, revalidated against its identity.
Returns None when processes is not the slice the tree was built from, so
a stale tree paired with a fresh snapshot yields nothing instead of the
wrong process (§26: a PID is not an identity).
Sourcepub fn ancestry<P: Borrow<ProcessSnapshot>>(
&self,
processes: &[P],
index: usize,
) -> Vec<AncestorEntry>
pub fn ancestry<P: Borrow<ProcessSnapshot>>( &self, processes: &[P], index: usize, ) -> Vec<AncestorEntry>
The §2.4 ancestry breadcrumb for a row, nearest parent first.
Matches the ordering of crate::model::ProcessDetail::ancestry so the
live tree and an on-demand detail read render identically. Entries that
cannot be revalidated against processes are skipped rather than guessed.
Trait Implementations§
Source§impl Clone for ProcessTree
impl Clone for ProcessTree
Source§fn clone(&self) -> ProcessTree
fn clone(&self) -> ProcessTree
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more