Struct mprober_lib::volume::VolumeStat
source · 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 copy 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
source§fn eq(&self, other: &VolumeStat) -> bool
fn eq(&self, other: &VolumeStat) -> bool
This method tests for
self and other values to be equal, and is used
by ==.impl Eq for VolumeStat
impl StructuralEq for VolumeStat
impl StructuralPartialEq for VolumeStat
Auto Trait Implementations§
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