Skip to content

Commit c278d89

Browse files
committed
current example: show loaded modules
1 parent beaf62a commit c278d89

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

examples/current.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
use rkmod::cache::InternCache;
2+
use rkmod::controller::SystemModuleController;
23
use rkmod::directory::ModuleDirectory;
34

45
fn main() {
56
let directory =
67
ModuleDirectory::current(InternCache::default()).expect("could not load module directory");
8+
let controller = SystemModuleController::default();
9+
let mut loaded: usize = 0;
10+
for module in directory.database().modules().values() {
11+
let is_live = controller.is_live(module.name().as_str()).unwrap_or(false);
12+
13+
if is_live {
14+
loaded += 1;
15+
}
16+
}
17+
718
println!(
8-
"{} has {} modules",
19+
"{} has {} modules ({} loaded)",
920
directory.root().to_string_lossy(),
10-
directory.database().modules().len()
21+
directory.database().modules().len(),
22+
loaded,
1123
);
1224
}

0 commit comments

Comments
 (0)