From a1c5f6dc8a70267d7dbffcf30635596615e3bab8 Mon Sep 17 00:00:00 2001 From: mskrasnov Date: Sat, 8 Aug 2026 18:09:29 +0300 Subject: [PATCH 1/8] [ferrix-lib] Add docs for the 'battery' module --- ferrix-lib/src/battery.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ferrix-lib/src/battery.rs b/ferrix-lib/src/battery.rs index a7711a0..8afde28 100644 --- a/ferrix-lib/src/battery.rs +++ b/ferrix-lib/src/battery.rs @@ -19,6 +19,16 @@ */ //! Get information about notebook's battery +//! +//! ## Example +//! ```no-test +//! use ferrix_lib::battery::BatInfo; +//! use ferrix_lib::traits::ToJson; +//! +//! let bat = BatInfo::new().unwrap(); +//! let bat_json = bat.to_json().unwrap(); +//! dbg!(bat_json); +//! ``` use anyhow::Result; use serde::{Deserialize, Serialize}; From 9d11116fa449375bf1f4431d8959b134388a89e5 Mon Sep 17 00:00:00 2001 From: mskrasnov Date: Sat, 8 Aug 2026 18:09:45 +0300 Subject: [PATCH 2/8] [ferrix-lib] Add docs for the 'cpu_freq' module --- ferrix-lib/src/cpu_freq.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ferrix-lib/src/cpu_freq.rs b/ferrix-lib/src/cpu_freq.rs index 58cbd33..83972da 100644 --- a/ferrix-lib/src/cpu_freq.rs +++ b/ferrix-lib/src/cpu_freq.rs @@ -19,6 +19,14 @@ */ //! Get information about CPU frequency +//! +//! ## Example +//! ```no-test +//! use ferrix_lib::cpu_freq::CpuFreq; +//! +//! let freqs = CpuFreq::new().unwrap(); +//! dbg!(&freqs.policy); +//! ``` use anyhow::{Result, anyhow}; use serde::{Deserialize, Serialize}; @@ -31,9 +39,15 @@ use std::{ use crate::traits::ToJson; +/// Information about power management and frequencies +/// for the processors installed in the PC #[derive(Debug, Deserialize, Serialize, Clone)] pub struct CpuFreq { + /// Information on power and frequency management + /// for each processor core/thread pub policy: Vec, + + /// Does the processor support Turbo Boost technology? pub boost: Option, } @@ -68,6 +82,8 @@ impl CpuFreq { impl ToJson for CpuFreq {} +/// Information about power management and the frequency +/// of a specific core/thread #[derive(Debug, Deserialize, Serialize, Default, Clone)] pub struct Policy { /// Maximum frequency from the BIOS From 003c897f40b6b3fdb9dd885b591d913a6299d859 Mon Sep 17 00:00:00 2001 From: mskrasnov Date: Sat, 8 Aug 2026 18:09:57 +0300 Subject: [PATCH 3/8] [ferrix-lib] Add docs for the 'desktop' module --- ferrix-lib/src/desktop.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ferrix-lib/src/desktop.rs b/ferrix-lib/src/desktop.rs index 0b60a25..593c3b9 100644 --- a/ferrix-lib/src/desktop.rs +++ b/ferrix-lib/src/desktop.rs @@ -28,8 +28,13 @@ use std::{env, fs, path::Path, process::Command}; /// Session info (desktop, window manager) #[derive(Debug, Clone, Serialize, Deserialize)] pub struct SessionInfo { + /// Desktop environment name pub desktop: Option, + + /// DE version pub desktop_ver: Option, + + /// Window manager/compositor name pub window_manager: Option, } From c49389a5054ee607c569758e9fab14c4aa293ee2 Mon Sep 17 00:00:00 2001 From: mskrasnov Date: Sat, 8 Aug 2026 18:11:48 +0300 Subject: [PATCH 4/8] [ferrix-lib] Remove outdated docs from the main module --- ferrix-lib/src/lib.rs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/ferrix-lib/src/lib.rs b/ferrix-lib/src/lib.rs index cd32348..f250bfa 100644 --- a/ferrix-lib/src/lib.rs +++ b/ferrix-lib/src/lib.rs @@ -22,18 +22,6 @@ //! hardware and software of a PC running Linux OS. //! //! ## Examples -//! Get all information about hardware and software (NOTE: needed -//! `root` permissions!): -//! ```no-test -//! use ferrix_lib::Ferrix; -//! -//! let data = Ferrix::new()?; // get all data -//! -//! let json_str = data.to_json()?; // get machine-readable JSON from this data -//! let pjson_str = data.to_json_pretty()?; // get human-readable JSON -//! let xml_str = data.to_xml()?; // get XML -//! ``` -//! //! Get information about CPU: //! ```no-test //! use ferrix_lib::cpu::Processors; @@ -42,6 +30,13 @@ //! let json_str = data.to_json()?; //! let pjson_str = data.to_json_pretty()?; //! ``` +//! +//! Get information about DMI tables (note: `root` permissions is needed!): +//! ```no-test +//! use ferrix_lib::dmi::DMITable; +//! let dmi = DMITable::new().unwrap(); +//! dbg!(dmi); +//! ``` #[cfg(feature = "battery")] pub mod battery; From 0254ecd78d4e4bd68b912fe3c76a60a93620bea5 Mon Sep 17 00:00:00 2001 From: mskrasnov Date: Sat, 8 Aug 2026 18:19:55 +0300 Subject: [PATCH 5/8] [ferrix-lib] Update README information --- ferrix-lib/README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/ferrix-lib/README.md b/ferrix-lib/README.md index 31cc462..6d8d5b8 100644 --- a/ferrix-lib/README.md +++ b/ferrix-lib/README.md @@ -34,6 +34,36 @@ TODO: - [ ] Get information about GUI (desktop environment, session type (Wayland or X.org), etc.); - [ ] Backup and reset `gsettings` settins; +## Features + +Now, `ferrix-lib` has a modular structure in which each module depends on a specific enabled feature. Since `ferrix-lib` is part of the [FSM](https://mskrasnov.github.io/fsm/) project by default, all features are enabled by default (`features.default`). + +Features list: + +- `battery`; +- `cpu`; +- `cpu_freq`; +- `desktop`; +- `dmi`; +- `drm`; +- `firmware`; +- `init` (DBus is needed); +- `mem`; +- `net`; +- `parts` (`glibc` is needed); +- `resources`; +- `soft`; +- `sys`; +- `vulnerabilities`; + +Using `ferrix-lib` with specific features: + +```bash +cargo add ferrix-lib \ + --no-default-features \ + --features=feature1,feature2,...,featuren +``` + ## License `ferrix-lib` is distributed under the GNU GPL v3 license. From 469c3d91e835ed7dabf1e1c978df31ff6457185a Mon Sep 17 00:00:00 2001 From: mskrasnov Date: Sat, 8 Aug 2026 18:30:45 +0300 Subject: [PATCH 6/8] [ferrix-lib] Add version difference notice --- ferrix-lib/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ferrix-lib/README.md b/ferrix-lib/README.md index 6d8d5b8..ca6a87f 100644 --- a/ferrix-lib/README.md +++ b/ferrix-lib/README.md @@ -4,7 +4,7 @@ > > **NOTE 2:** this crate is a part of [ferrix-app](https://crates.io/crates/ferrix-app) crate. -Crate to get information about PC's hardware and software. Only for Linux. Some features are requires `d-bus` and `systemd`. Supported features: get information about: +Crate to get information about PC's hardware and software. Only for Linux. Some features are requires `d-bus` and `systemd`. This crate can get information about: - CPU (`/proc/cpuinfo`); - RAM (`/proc/meminfo`) and swaps (`/proc/swaps`); @@ -34,6 +34,8 @@ TODO: - [ ] Get information about GUI (desktop environment, session type (Wayland or X.org), etc.); - [ ] Backup and reset `gsettings` settins; +At this time, the API is stable, and changes between versions are very minor. All changes are made primarily to further the development of the FSM project (adding new data sources). + ## Features Now, `ferrix-lib` has a modular structure in which each module depends on a specific enabled feature. Since `ferrix-lib` is part of the [FSM](https://mskrasnov.github.io/fsm/) project by default, all features are enabled by default (`features.default`). From defd9368cbb3c1606af78ab0491af99b4890e587 Mon Sep 17 00:00:00 2001 From: mskrasnov Date: Sat, 8 Aug 2026 18:43:51 +0300 Subject: [PATCH 7/8] [ferrix-lib] Add docs to the 'firmware' module --- ferrix-lib/src/firmware.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ferrix-lib/src/firmware.rs b/ferrix-lib/src/firmware.rs index 514132b..a95acc5 100644 --- a/ferrix-lib/src/firmware.rs +++ b/ferrix-lib/src/firmware.rs @@ -19,6 +19,16 @@ */ //! Get firmware settings (only for modern systems with UEFI) +//! +//! > **Note:** you need to be `root` for get this information. +//! +//! ## Example +//! ```no-test +//! use ferrix_lib::firmware::Firmware; +//! let f = Firmware::new().unwrap(); +//! println!("WMI Driver: {}", &f.driver_name); +//! dbg!(&f.attributes); +//! ``` use anyhow::{Result, anyhow}; use serde::{Deserialize, Serialize}; From 62db979d9c160f07bddf1878fa46d6a92e870d55 Mon Sep 17 00:00:00 2001 From: mskrasnov Date: Sat, 8 Aug 2026 18:44:04 +0300 Subject: [PATCH 8/8] [ferrix-lib] Add docs for the 'init' module --- ferrix-lib/src/init.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/ferrix-lib/src/init.rs b/ferrix-lib/src/init.rs index 6a2bf47..6e40b54 100644 --- a/ferrix-lib/src/init.rs +++ b/ferrix-lib/src/init.rs @@ -19,6 +19,19 @@ */ //! Get information about `systemd` services +//! +//! ## Usage +//! ```no-test +//! use ferrix_lib::init::SystemdServices; +//! use zbus::Connection; +//! +//! let mut conn = Connection::system().await.unwrap(); +//! let systemd = SystemdServices::new_from_connection(&conn) +//! .await +//! .unwrap(); +//! +//! dbg!(systemd); +//! ``` use anyhow::{Result, anyhow}; use libc::{CLOCK_MONOTONIC, CLOCK_REALTIME, clock_gettime, timespec}; @@ -37,6 +50,19 @@ pub struct SystemdServices { } impl SystemdServices { + /// Get current systemd services + /// + /// ## Usage + /// ```no-test + /// use ferrix_lib::init::SystemdServices; + /// use zbus::Connection; + /// + /// let mut conn = Connection::system().await.unwrap(); + /// let sysd = SystemdServices::new_from_connection(&conn) + /// .await + /// .unwrap(); + /// dbg!(&sysd.units); + /// ``` pub async fn new_from_connection(conn: &Connection) -> Result { let mgr = ManagerProxy::new(conn).await?; let mut units = vec![];