Summary
The AllSmi library currently provides public methods for retrieving GPU, CPU, memory, and chassis information, but lacks a method for storage/disk information despite having the internal implementation.
This enhancement would complete the resource information API surface and provide library users with programmatic access to disk information.
Current State
StorageInfo struct already exists at src/storage/info.rs
- Disk collection using
sysinfo::Disks is implemented in local_collector.rs and api/server.rs
- Storage info is only accessible internally via
AppState
- Other resources have public API methods:
get_gpu_info() -> Vec<GpuInfo>
get_cpu_info() -> Vec<CpuInfo>
get_memory_info() -> Vec<MemoryInfo>
get_chassis_info() -> Option<ChassisInfo>
Proposed Solution
- Create a
StorageReader trait following the existing reader pattern (similar to GpuReader, CpuReader, MemoryReader, ChassisReader)
- Add
storage_reader field to AllSmi struct in src/client.rs
- Implement
get_storage_info() -> Vec<StorageInfo> method on AllSmi
- Reuse existing
filter_docker_aware_disks() utility from src/utils.rs
Implementation Details
| Component |
Location |
Description |
StorageReader trait |
src/storage/reader.rs (new) |
Define the reader interface |
LocalStorageReader |
src/storage/reader.rs (new) |
Implementation using sysinfo::Disks |
AllSmi modification |
src/client.rs |
Add storage_reader field and get_storage_info() method |
| Public exports |
src/lib.rs |
Export StorageInfo and related types |
Example API Usage
use all_smi::AllSmi;
let smi = AllSmi::new();
for storage in smi.get_storage_info() {
println!("Disk: {} ({:?})", storage.name, storage.kind);
println!(" Mount: {}", storage.mount_point);
println!(" Total: {} bytes", storage.total_space);
println!(" Used: {} bytes", storage.used_space);
println!(" Available: {} bytes", storage.available_space);
}
Benefits
- Consistent API design: Matches the pattern of other resource types
- Library accessibility: Users can access disk information programmatically without using the TUI or API server
- Code reuse: Leverages existing
StorageInfo struct and filter_docker_aware_disks() utility
- Minimal changes: Follows established patterns, reducing implementation complexity
Acceptance Criteria
Summary
The AllSmi library currently provides public methods for retrieving GPU, CPU, memory, and chassis information, but lacks a method for storage/disk information despite having the internal implementation.
This enhancement would complete the resource information API surface and provide library users with programmatic access to disk information.
Current State
StorageInfostruct already exists atsrc/storage/info.rssysinfo::Disksis implemented inlocal_collector.rsandapi/server.rsAppStateget_gpu_info() -> Vec<GpuInfo>get_cpu_info() -> Vec<CpuInfo>get_memory_info() -> Vec<MemoryInfo>get_chassis_info() -> Option<ChassisInfo>Proposed Solution
StorageReadertrait following the existing reader pattern (similar toGpuReader,CpuReader,MemoryReader,ChassisReader)storage_readerfield toAllSmistruct insrc/client.rsget_storage_info() -> Vec<StorageInfo>method onAllSmifilter_docker_aware_disks()utility fromsrc/utils.rsImplementation Details
StorageReadertraitsrc/storage/reader.rs(new)LocalStorageReadersrc/storage/reader.rs(new)sysinfo::DisksAllSmimodificationsrc/client.rsstorage_readerfield andget_storage_info()methodsrc/lib.rsStorageInfoand related typesExample API Usage
Benefits
StorageInfostruct andfilter_docker_aware_disks()utilityAcceptance Criteria
StorageReadertrait insrc/storage/reader.rsLocalStorageReaderusingsysinfo::Disksstorage_readerfield toAllSmistructget_storage_info() -> Vec<StorageInfo>methodStorageInfoin public API (src/lib.rs)examples/library_usage.rswith storage info example