sinf 0.1.0

Library for obtaining in-depth system information at both the hardware and software levels
Documentation
# API reference

`sinf` exposes one public module per domain. Each module is enabled by its
Cargo feature and can be used independently. The full rustdoc is the method
reference; this page summarizes the public surface and the common patterns.

## Modules

| Module | Feature | Main types |
|---|---|---|
| `sinf::hardware` | `hardware` | `Hardware`, `Bios`, `Board`, `Chassis`, `MemoryDevice`, `NetworkDevice`, `PciDevice`, `UsbDevice`, `Battery`, `Sensor`, `SensorKind`, `Display`, `StorageDevice` |
| `sinf::system` | `system` | `System`, `Process`, `Cpu`, `Motherboard`, `Product`, `Pid`, `RefreshKind`, `CpuRefreshKind`, `MemoryRefreshKind`, `ProcessRefreshKind`, `ProcessesToUpdate`, `UpdateKind`, `ProcessStatus`, `Signal`, `LoadAvg`, `CGroupLimits`, `KillError`, `ThreadKind` |
| `sinf::disk` | `disk` | `Disk`, `Disks`, `DiskKind`, `DiskRefreshKind` |
| `sinf::component` | `component` | `Component`, `Components` |
| `sinf::gpu` | `gpu` | `Gpu`, `Gpus`, `PCI` |
| `sinf::network` | `network` | `Networks`, `NetworkData`, `MacAddr`, `IpNetwork`, `InterfaceOperationalState` |
| `sinf::user` | `user` | `User`, `Users`, `Group`, `Groups` |
| `sinf::common` | shared | `DiskUsage`, `Uid`, `Gid` |
| `sinf::prelude` | shared | Convenience re-exports |
| `sinf::Error` | shared | Error type |


## Source layout

| Public module | Source |
|---|---|
| `sinf::system` | `src/system/` |
| `sinf::disk` | `src/disk/` |
| `sinf::component` | `src/component/` |
| `sinf::gpu` | `src/gpu/` |
| `sinf::network` | `src/network/` |
| `sinf::user` | `src/user/` |
| `sinf::hardware` | `src/hardware/` |
| `sinf::common` | `src/common/` |
| `sinf::prelude` | `src/prelude.rs` |
| `sinf::fuzzing` | hidden for `fuzz/` |

The public modules are wired in `src/lib.rs`. They use `#![forbid(unsafe_code)]`;
OS access is behind the safe boundary described in
[structural conventions](structure.md#ffi-safety-boundary).

## Error handling

Fallible constructors return `Result<T, sinf::Error>`. Refresh methods return
`()` or a count, as documented on each method; when a backend refresh fails, the
previous snapshot is kept instead of panicking.

- `Error::Unsupported`: the target or feature cannot provide the information.
- `Error::Io`: an I/O error happened while reading the underlying source.
- `Error::Other`: any other backend error.

## Hardware inventory

`Hardware::new()` returns a snapshot with firmware (BIOS/board/chassis and
SMBIOS memory modules), PCI devices, USB devices, batteries, sensors, displays
and physical storage devices. `Hardware::refresh()` reloads it.

Hardware inventory is implemented on Linux through sysfs/procfs; unsupported
platforms return `Error::Unsupported`. Missing permissions or drivers produce
empty fields or lists, not hard failures.

## System

`System` owns the refreshable system state. Keep one instance alive instead of
rebuilding it:

```rust
use sinf::system::{RefreshKind, System};

let mut sys = System::new_with_specifics(RefreshKind::everything())?;
sys.refresh_all();
```

Key groups of methods:

- Construction: `new`, `new_all`, `new_with_specifics`.
- Refresh: `refresh_all`, `refresh_specifics`, `refresh_memory_specifics`,
  `refresh_cpu_*`, `refresh_processes*`.
- Processes: `processes`, `process`, `processes_by_name`,
  `processes_by_exact_name`.
- CPU: `cpus`, `global_cpu_usage`.
- Memory: `total_memory`, `free_memory`, `available_memory`, `used_memory`,
  `total_swap`, `free_swap`, `used_swap`, `cgroup_limits`.
- Static information: `name`, `kernel_version`, `os_version`,
  `long_os_version`, `distribution_id`, `distribution_id_like`,
  `kernel_long_version`, `host_name`, `cpu_arch`, `uptime`, `boot_time`,
  `load_average`, `physical_core_count`, `open_files_limit`.

`Process` exposes the process identity, command line, executable, cwd, root,
environment, memory, CPU, disk usage, status, user/group IDs, tasks and signal
operations. Tasks (threads) are excluded by default; enable them with
`ProcessRefreshKind::with_tasks()`. `Cpu` exposes name, brand, vendor, frequency and usage.

Refresh kinds select what is refreshed. Start at `nothing` and add only what is
needed; `everything` refreshes all supported fields.

## Collections

`Disks`, `Components`, `Gpus`, `Users`, `Groups` and `Networks` follow the same
shape:

- `new()` creates an empty collection.
- `new_with_refreshed_list()` creates and refreshes it.
- `refresh(...)` updates it.
- They implement `Deref` to a slice (or map for `Networks`) and
  `IntoIterator` for `&` and `&mut` where applicable.
- `From<Collection> for Vec<T>` is available on most of them.

```rust
use sinf::disk::Disks;

let disks = Disks::new_with_refreshed_list()?;
for disk in &disks {
    println!("{:?}", disk.name());
}
```

## Disks

`Disk` exposes `kind`, `id`, `name`, `file_system`, `mount_point`,
`total_space`, `available_space`, `is_removable`, `is_read_only`, `usage`,
`refresh` and `refresh_specifics`.

`DiskRefreshKind` selects `kind`, `storage`, `io_usage` and `network`. Network
mounts are excluded by default; enabling `network` can hang on Linux with hard
CIFS/NFS mounts.

## Network

`Networks` is a map from interface name (`OsString`) to `NetworkData`.
`NetworkData` exposes byte/packet/error counters, `mac_address`,
`ip_networks`, `mtu`, `transmit_link_speed`, `receive_link_speed` and
`operational_state`. Delta counters (`received`, `transmitted`, ...) require
two refreshes; total counters (`total_received`, ...) are accumulated.

`MacAddr` and `IpNetwork` parse from strings and implement `Display`.
`InterfaceOperationalState` mirrors the RFC 2863 interface states.

## Users and groups

`Users` and `Groups` list the local user/group database. `User` and `Group`
expose `id` and `name`; `User` also exposes `group_id` (an `Option`, since a
primary group may not be available) and `groups()`.
`Users::get_user_by_id` resolves a process UID when the user database is
loaded. `Uid` and `Gid` live in `sinf::common` and implement `Deref`, `FromStr`
and `TryFrom<usize>` where the platform supports it. On Windows both wrap a
security identifier (SID); `Group::id` is the group SID and `User::group_id`
returns `Some(SID)` when the primary group can be resolved.

## Components and GPUs

`Component` exposes `temperature`, `max`, `critical`, `label`, `id` and
`refresh`. Values can be `None` when the platform or driver does not expose the
sensor.

`Gpu` exposes `pci`, `vendor`, `model`, `usage`, `total_memory` and
`used_memory`. GPU support depends on the platform and drivers; Apple M-series
GPUs use a synthetic PCI address. Vendor names come from the embedded
[PCI vendor ID table](reference/pci-vendor-ids.md).

## serde

With the `serde` feature, live snapshots implement `Serialize` and value types
implement both `Serialize` and `Deserialize`. See [serde support](serde.md) for
the stable field names, identifier representation and privacy notes.

## Threading

Snapshot types are `Send` and `Sync` on the supported targets, but platform
opaque state can impose extra bounds. The `multithread` feature enables parallel
refreshes with `rayon`; otherwise refreshes run sequentially. CPU and process
usage require at least `MINIMUM_CPU_UPDATE_INTERVAL` between reads.

## Platform support

| Platform | Backend |
|---|---|
| Linux / Android / Raspberry Pi | `platform/linux` |
| FreeBSD | `platform/freebsd` |
| NetBSD | `platform/netbsd` |
| macOS / iOS | `platform/apple` |
| Windows | `platform/windows` |


See [features.md](features.md) for the feature matrix and
[structure.md](structure.md) for the code organization.