Skip to main content

ProcessTree

Struct ProcessTree 

Source
pub struct ProcessTree { /* private fields */ }
Expand description

A process tree flattened into display order.

Implementations§

Source§

impl ProcessTree

Source

pub fn from_snapshot(snapshot: &SystemSnapshot, sort: ProcessSort) -> Self

Builds the tree of every process in snapshot.

Source

pub fn from_snapshot_filtered( snapshot: &SystemSnapshot, sort: ProcessSort, filter: &ProcessFilter, ) -> Self

Builds the tree of the processes in snapshot that pass filter.

Source

pub fn build<P: Borrow<ProcessSnapshot>>( processes: &[P], sort: ProcessSort, ) -> Self

Builds the tree of every process in processes.

Source

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.

Source

pub fn rows(&self) -> &[TreeRow]

Every row, in display order.

Source

pub fn len(&self) -> usize

How many rows the tree has.

Source

pub fn is_empty(&self) -> bool

Whether the tree has no rows.

Source

pub fn row(&self, index: usize) -> Option<&TreeRow>

The row at index, if there is one.

Source

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).

Source

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.

Source

pub fn max_depth(&self) -> u32

The deepest indentation level in the tree.

Source

pub fn subtree_len(&self, index: usize) -> usize

The number of rows this row occupies together with its subtree.

Source

pub fn child_rows(&self, index: usize) -> Vec<usize>

The direct children of a row, in display order (§2.4 child navigation).

Source

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.

Source

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.

Source

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).

Source

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

Source§

fn clone(&self) -> ProcessTree

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ProcessTree

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ProcessTree

Source§

fn default() -> ProcessTree

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.