Skip to main content

FlashOps

Struct FlashOps 

Source
pub struct FlashOps {
    pub reads: u64,
    pub read_bytes: u64,
    pub writes: u64,
    pub erases: u64,
}
Available on crate feature std only.
Expand description

A snapshot of a MockFlash’s operation counters.

Subtracting two snapshots gives the cost of whatever happened between them, which is the portable and deterministic way to measure this crate: on real hardware an erase is 100 ms or more, a page write is microseconds, and a read is bus-bound, so the counts predict behaviour across parts in a way a desktop wall-clock number never can.

let mut db: SensorDb<MockFlash<256, 4096>, 256, 8> =
    SensorDb::new(MockFlash::new(8 * 4096), 0, 8, 1)?;
db.format()?;

let before = db.driver_mut().ops();
db.append(1, 0, &[0xAB])?;
// A buffered append touches no flash at all.
assert_eq!(db.driver_mut().ops() - before, Default::default());

Fields§

§reads: u64

Read operations.

§read_bytes: u64

Bytes read. The number that matters for mount cost on a real bus.

§writes: u64

Page-program operations, successful or torn.

§erases: u64

Sector-erase operations, successful or torn. The expensive one.

Trait Implementations§

Source§

impl Clone for FlashOps

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for FlashOps

Source§

impl Debug for FlashOps

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for FlashOps

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for FlashOps

Source§

impl PartialEq for FlashOps

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for FlashOps

Source§

impl Sub for FlashOps

Source§

fn sub(self, earlier: Self) -> Self

The cost between two snapshots.

Saturating, so an accidentally reversed subtraction reads as zero rather than as an enormous count.

Source§

type Output = FlashOps

The resulting type after applying the - operator.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.