FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    MemoizingMRUCache

    struct · ferroui-splat · v0.5.0

    struct MemoizingMRUCache<K, V>
    

    A cache of the values of a function, which keeps the most recently used ones (MemoizingMRUCache<TParam, TVal>): get returns the cached value of a key, or computes it and evicts the least recently used value when the cache is full. Evicted and invalidated values are handed to the release function.

    Keys compare with PartialEq or with a comparer (IEqualityComparer<TParam>).

    View source

    Members

    new

    fn new(calculation_func: impl Fn(&K, Option<&dyn Any>) -> V + 'static, max_size: usize) -> Self
    

    A cache of calculation_func with at most max_size values (MemoizingMRUCache(Func<TParam, object?, TVal>, int)).

    Panics when max_size is 0 (ArgumentOutOfRangeException).

    Source

    with_release

    fn with_release(calculation_func: impl Fn(&K, Option<&dyn Any>) -> V + 'static, max_size: usize, on_release: impl Fn(V) -> () + 'static) -> Self
    

    A cache that hands evicted and invalidated values to on_release (MemoizingMRUCache(Func<TParam, object?, TVal>, int, Action<TVal>)).

    Source

    with_comparer

    fn with_comparer(calculation_func: impl Fn(&K, Option<&dyn Any>) -> V + 'static, max_size: usize, param_comparer: impl Fn(&K, &K) -> bool + 'static) -> Self
    

    A cache whose keys compare with param_comparer (MemoizingMRUCache(Func<TParam, object?, TVal>, int, IEqualityComparer<TParam>)).

    Source

    with_release_and_comparer

    fn with_release_and_comparer(calculation_func: impl Fn(&K, Option<&dyn Any>) -> V + 'static, max_size: usize, on_release: Option<impl Fn(V) -> () + 'static>, param_comparer: impl Fn(&K, &K) -> bool + 'static) -> Self
    

    A cache with a release function and a comparer of keys (MemoizingMRUCache(Func<TParam, object?, TVal>, int, Action<TVal>?, IEqualityComparer<TParam>)).

    Panics when max_size is 0 (ArgumentOutOfRangeException).

    Source

    get

    fn get(self: &Self, key: K) -> V
    

    The value of key, computed on a miss (Get(TParam)).

    Source

    get_with_context

    fn get_with_context(self: &Self, key: K, context: Option<&dyn Any>) -> V
    

    The value of key, computed with context on a miss (Get(TParam, object?)).

    Source

    try_get

    fn try_get(self: &Self, key: &K) -> Option<V>
    

    The cached value of key, without computing it (TryGet).

    Source

    invalidate

    fn invalidate(self: &Self, key: &K)
    

    Removes key and releases its value (Invalidate).

    Source

    invalidate_all

    fn invalidate_all(self: &Self)
    

    Removes every value and releases them; a panic of the release function stops the release (InvalidateAll()).

    Source

    invalidate_all_with

    fn invalidate_all_with(self: &Self, aggregate_release_exceptions: bool) -> Result<(), AggregateReleaseError>
    

    Removes every value and releases them (InvalidateAll(bool)). With aggregate_release_exceptions, every value is released even when the release function panics, and the panics are returned together; otherwise the first panic propagates.

    Source

    cached_values

    fn cached_values(self: &Self) -> Vec<V>
    

    The cached values (CachedValues).

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • Borrow<T>
    • BorrowMut<T>
    • Into<U>
    • From<T>
    • TryInto<U>
    • TryFrom<U>
    • Any

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.