pub struct VolumeStat {
pub read_bytes: u64,
pub write_bytes: u64,
}Fields§
§read_bytes: u64§write_bytes: u64Implementations§
Source§impl VolumeStat
impl VolumeStat
Sourcepub fn compute_speed(
&self,
volume_stat_after_this: &VolumeStat,
interval: Duration,
) -> VolumeSpeed
pub fn compute_speed( &self, volume_stat_after_this: &VolumeStat, interval: Duration, ) -> VolumeSpeed
Calculate speed between two VolumeStat instances at different time.
use std::{thread::sleep, time::Duration};
use mprober_lib::volume;
let pre_volumes = volume::get_volumes().unwrap();
let interval = Duration::from_millis(100);
sleep(interval);
let volumes = volume::get_volumes().unwrap();
if !pre_volumes.is_empty() && !volumes.is_empty() {
let volume_speed =
pre_volumes[0].stat.compute_speed(&volumes[0].stat, interval);
println!("Read: {:.1} B/s", volume_speed.read);
println!("Write: {:.1} B/s", volume_speed.write);
}Trait Implementations§
Source§impl Clone for VolumeStat
impl Clone for VolumeStat
Source§fn clone(&self) -> VolumeStat
fn clone(&self) -> VolumeStat
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for VolumeStat
impl Debug for VolumeStat
Source§impl Default for VolumeStat
impl Default for VolumeStat
Source§fn default() -> VolumeStat
fn default() -> VolumeStat
Returns the “default value” for a type. Read more
Source§impl PartialEq for VolumeStat
impl PartialEq for VolumeStat
impl Eq for VolumeStat
impl StructuralPartialEq for VolumeStat
Auto Trait Implementations§
impl Freeze for VolumeStat
impl RefUnwindSafe for VolumeStat
impl Send for VolumeStat
impl Sync for VolumeStat
impl Unpin for VolumeStat
impl UnwindSafe for VolumeStat
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
Mutably borrows from an owned value. Read more