[][src]Struct memflow::mem::cache::count_validator::CountCacheValidator

pub struct CountCacheValidator { /* fields omitted */ }

Validator for limiting the cache time based on a time Instant

Remarks

This validator is only available when being compiled with std. When using no_std you might want to use another validator. TODO: add other validators here

Implementations

impl CountCacheValidator[src]

pub fn new(valid_count: usize) -> Self[src]

Creates a new CountCacheValidator with a customizable valid count.

Valid count is increased on every memory operation by the validator users.

Examples:

use memflow::mem::CountCacheValidator;
use memflow::CacheValidator;

let mut validator = CountCacheValidator::new(100);

validator.allocate_slots(1);

assert!(!validator.is_slot_valid(0));
validator.validate_slot(0);

// For a hundred times the slot should stay valid
for _ in 0..100 {
    assert!(validator.is_slot_valid(0));
    validator.update_validity();
}

// At this point it should become invalid
assert!(!validator.is_slot_valid(0));

Trait Implementations

impl CacheValidator for CountCacheValidator[src]

impl Clone for CountCacheValidator[src]

impl Default for CountCacheValidator[src]

Creates a validator with a cache timeout of 1 second.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.