summaryrefslogtreecommitdiffstats
path: root/src/kernel/mod.rs
blob: af358dfdb5bcbc32173bb8dd7603c20c22598d07 (plain)
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
pub mod cmd;
pub mod info;
pub mod lkm;
pub mod log;
use crate::style::Style;
use clap::ArgMatches;
use info::KernelInfo;
use lkm::{KernelModules, ListArgs};
use log::KernelLogs;

/* Kernel struct for logs, information and modules */
pub struct Kernel {
	pub logs: KernelLogs,
	pub info: KernelInfo,
	pub modules: KernelModules<'static>,
}

impl Kernel {
	/**
	 * Create a new kernel instance.
	 *
	 * @param  ArgMatches
	 * @return Kernel
	 */
	pub fn new(args: &ArgMatches) -> Self {
		Self {
			logs: KernelLogs::default(),
			info: KernelInfo::new(),
			modules: KernelModules::new(ListArgs::new(args), Style::new(args)),
		}
	}

	/* Refresh kernel logs, modules and information. */
	pub fn refresh(&mut self) {
		self.logs.refresh();
		self.info.refresh();
		self.modules.refresh();
	}
}