pub struct LocalStorageReader { /* private fields */ }Expand description
Local storage reader using sysinfo::Disks.
This reader collects storage information from the local system using
the sysinfo crate. It applies Docker-aware filtering to exclude
system directories and Docker-specific bind mounts.
The disk list is kept between calls in a DiskCache, so repeated calls
(the record loop, a library consumer polling) enumerate the mount table
at most every 30 s rather than on every call; a volume mounted in the
meantime appears within 30 s.
The first call enumerates the mount table on the calling thread and
returns the complete list however long that takes, as this reader always
has. The view and API collection loops use a cache whose first call waits
at most 2 s instead, so a hung mount cannot stall their first tick (see
DiskCache::with_blocking_first_list and DiskCache::new).
§Example
use all_smi::storage::{LocalStorageReader, StorageReader};
let reader = LocalStorageReader::new();
for storage in reader.get_storage_info() {
let used_bytes = storage.total_bytes - storage.available_bytes;
let usage_percent = if storage.total_bytes > 0 {
(used_bytes as f64 / storage.total_bytes as f64) * 100.0
} else {
0.0
};
println!("{}: {:.1}% used", storage.mount_point, usage_percent);
}Implementations§
Trait Implementations§
Source§impl Default for LocalStorageReader
impl Default for LocalStorageReader
Source§impl StorageReader for LocalStorageReader
impl StorageReader for LocalStorageReader
Source§fn get_storage_info(&self) -> Vec<StorageInfo>
fn get_storage_info(&self) -> Vec<StorageInfo>
Auto Trait Implementations§
impl !Freeze for LocalStorageReader
impl Forget for LocalStorageReader
impl Move for LocalStorageReader
impl RefUnwindSafe for LocalStorageReader
impl Send for LocalStorageReader
impl Sync for LocalStorageReader
impl Unpin for LocalStorageReader
impl UnsafeUnpin for LocalStorageReader
impl UnwindSafe for LocalStorageReader
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request