Skip to main content

IoSampler

Struct IoSampler 

Source
pub struct IoSampler { /* private fields */ }
Expand description

Measures disk activity between samples. Owned by the caller. sample never blocks and allocates nothing.

use std::time::Duration;

let mut disks = sys_lib::disk::IoSampler::new()?;
std::thread::sleep(Duration::from_secs(5));
let io = disks.sample()?;
println!("read {} write {}", io.read, io.write);
for d in disks.sample_per_disk()? {
    println!("  {}: busy {:?}", d.device, d.io.busy);
}

Implementations§

Source§

impl IoSampler

Source

pub fn new() -> Result<IoSampler>

Takes the first reading, of the total and of each disk.

§Errors

As io_totals.

Source

pub fn sample(&mut self) -> Result<DiskIo>

Activity since the previous sample, every physical disk together. A counter that went backwards re-bases the sampler and reads as no activity for that interval.

§Errors

TooSoon when no time passed since the previous sample.

Source

pub fn sample_per_disk(&mut self) -> Result<Vec<DeviceIo>>

Activity since the previous per-disk sample, for each disk (allocates the Vec). A disk seen for the first time reads as no activity.

§Errors

TooSoon when no time passed since the previous sample.

Trait Implementations§

Source§

impl Debug for IoSampler

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.