Skip to main content

ProcessStore

Trait ProcessStore 

Source
pub trait ProcessStore {
    // Required methods
    fn get_process(&self, pid: u32) -> Option<ProcessInfo>;
    fn insert_process(&self, pid: u32, info: ProcessInfo);
    fn remove_process(&self, pid: u32) -> Option<ProcessInfo>;
    fn all_pids(&self) -> Vec<u32>;
    fn for_each_child(&self, pid: u32, f: &mut dyn FnMut(u32));

    // Provided method
    fn children_of(&self, pid: u32) -> Vec<u32> { ... }
}
Expand description

Trait for process tree storage.

Implement this trait to provide your own storage backend.

Required Methods§

Source

fn get_process(&self, pid: u32) -> Option<ProcessInfo>

Get process info by PID.

Source

fn insert_process(&self, pid: u32, info: ProcessInfo)

Insert or update process info.

Source

fn remove_process(&self, pid: u32) -> Option<ProcessInfo>

Remove a process by PID. Returns the removed process info.

Source

fn all_pids(&self) -> Vec<u32>

Get all PIDs in the tree.

Source

fn for_each_child(&self, pid: u32, f: &mut dyn FnMut(u32))

Iterate direct children of a PID.

Calls f for each child PID. Avoids allocating a return Vec.

Provided Methods§

Source

fn children_of(&self, pid: u32) -> Vec<u32>

Get direct children of a PID as a Vec.

Convenience wrapper around for_each_child.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§