Struct mprober_lib::volume::VolumeStat
source · [−]Fields
read_bytes: u64write_bytes: u64Implementations
sourceimpl 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.
extern crate mprober_lib;
use std::thread::sleep;
use std::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
sourceimpl Clone for VolumeStat
impl Clone for VolumeStat
sourcefn clone(&self) -> VolumeStat
fn clone(&self) -> VolumeStat
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl Debug for VolumeStat
impl Debug for VolumeStat
sourceimpl Default for VolumeStat
impl Default for VolumeStat
sourcefn default() -> VolumeStat
fn default() -> VolumeStat
Returns the “default value” for a type. Read more
sourceimpl PartialEq<VolumeStat> for VolumeStat
impl PartialEq<VolumeStat> for VolumeStat
sourcefn 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 ==. Read more
sourcefn ne(&self, other: &VolumeStat) -> bool
fn ne(&self, other: &VolumeStat) -> bool
This method tests for !=.
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more