ByMemoryUsage

Struct ByMemoryUsage 

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

A limiter for a map which is limited by memory usage.

Implementations§

Source§

impl ByMemoryUsage

Source

pub const fn new(max_bytes: usize) -> Self

Creates a new memory usage limiter with a given limit in bytes.

Source

pub const fn max_memory_usage(&self) -> usize

Returns the max memory usage.

Trait Implementations§

Source§

impl Clone for ByMemoryUsage

Source§

fn clone(&self) -> ByMemoryUsage

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ByMemoryUsage

Source§

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

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

impl<K, V> Limiter<K, V> for ByMemoryUsage

Source§

type KeyToInsert<'a> = K

The type of the key to be inserted into the map. Read more
Source§

type LinkType = u32

The type used to hold the links between the nodes inside of the LRU map. Read more
Source§

fn is_over_the_limit(&self, _: usize) -> bool

Checks whether any of the elements must be popped. Read more
Source§

fn on_insert( &mut self, _length: usize, key: Self::KeyToInsert<'_>, value: V, ) -> Option<(K, V)>

Called before a node is inserted into the map. Read more
Source§

fn on_replace( &mut self, _length: usize, _old_key: &mut K, _new_key: K, _old_value: &mut V, _new_value: &mut V, ) -> bool

Called before a value is replaced inside of the map. Read more
Source§

fn on_removed(&mut self, _key: &mut K, _value: &mut V)

Called after an element is removed from the map. Read more
Source§

fn on_cleared(&mut self)

Called after the map is cleared. Read more
Source§

fn on_grow(&mut self, new_memory_usage: usize) -> bool

Called before the map is resized. Read more
Source§

impl Copy for ByMemoryUsage

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.