1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//! # proc-tree
//!
//! Linux process tree: snapshot, incremental maintenance via fork/exec events,
//! ancestry chain queries, and PID reuse detection.
//!
//! ## Quick Start
//!
//! ```rust
//! use proc_tree::{TreeStore, CacheStore, PidNode, ProcInfo, ProcEvent};
//! use proc_tree::{snapshot, resolve, handle_events, build_chain_string};
//!
//! // Implement your own storage (or use a provided example)
//! # struct MyTree;
//! # impl TreeStore for MyTree {
//! # fn get_node(&self, pid: u32) -> Option<PidNode> { None }
//! # fn insert_node(&self, pid: u32, node: PidNode) {}
//! # fn all_pids(&self) -> Vec<u32> { vec![] }
//! # }
//! # struct MyCache;
//! # impl CacheStore for MyCache {
//! # fn get_info(&self, pid: u32) -> Option<ProcInfo> { None }
//! # fn insert_info(&self, pid: u32, info: ProcInfo) {}
//! }
//!
//! let tree = MyTree;
//! let cache = MyCache;
//!
//! // Seed from /proc
//! snapshot(&tree, &cache);
//!
//! // Resolve a PID
//! if let Some(info) = resolve(&cache, 1) {
//! println!("PID 1: cmd={}, user={}", info.cmd, info.user);
//! }
//!
//! // Build ancestry chain
//! let s = build_chain_string(&tree, &cache, 1234);
//! println!("Chain: {}", s);
//!
//! // Handle events
//! handle_events(&tree, &cache, &[
//! ProcEvent::Fork { child_pid: 200, parent_pid: 100, timestamp_ns: 0 },
//! ]);
//! ```
//!
//! ## PID Reuse Detection
//!
//! When a process exits and its PID is reused by a new process, cached data
//! becomes stale. `CacheStore` implementations should compare `start_time_ns`
//! with the current `/proc` value to detect reuse.
// Public API — types
pub use ProcInfo;
pub use PidNode;
// Public API — traits
pub use ;
// Public API — default implementations
pub use ;
// Public API — tree types
pub use ;
// Public API — operations
pub use ;
// Public API — proc utilities
pub use proc::;