Trait ApplyCache

Source
pub trait ApplyCache<M: Manager, O: Copy>: DropWith<M::Edge> {
    // Required methods
    fn get_with_numeric(
        &self,
        manager: &M,
        operator: O,
        operands: &[Borrowed<'_, M::Edge>],
        numeric_operands: &[u32],
    ) -> Option<M::Edge>;
    fn add_with_numeric(
        &self,
        manager: &M,
        operator: O,
        operands: &[Borrowed<'_, M::Edge>],
        numeric_operands: &[u32],
        value: Borrowed<'_, M::Edge>,
    );
    fn clear(&self, manager: &M);

    // Provided methods
    fn get(
        &self,
        manager: &M,
        operator: O,
        operands: &[Borrowed<'_, M::Edge>],
    ) -> Option<M::Edge> { ... }
    fn add(
        &self,
        manager: &M,
        operator: O,
        operands: &[Borrowed<'_, M::Edge>],
        value: Borrowed<'_, M::Edge>,
    ) { ... }
}
Expand description

Cache for the result of apply operations

This trait provides methods to add computation results to the apply cache and to query the cache for these results. Just as every cache, the implementation may decide to evict results from the cache.

Required Methods§

Source

fn get_with_numeric( &self, manager: &M, operator: O, operands: &[Borrowed<'_, M::Edge>], numeric_operands: &[u32], ) -> Option<M::Edge>

Get the result of operation, if cached

Source

fn add_with_numeric( &self, manager: &M, operator: O, operands: &[Borrowed<'_, M::Edge>], numeric_operands: &[u32], value: Borrowed<'_, M::Edge>, )

Add the result of operation to this cache

An implementation is free to not cache any result. (This is why we use Borrowed<M::Edge>, which in this case elides a few clone and drop operations.) If the cache already contains a key equal to operation, there is no need to update its value. (Again, we can elide clone and drop operations.)

Source

fn clear(&self, manager: &M)

Remove all entries from the cache

Provided Methods§

Source

fn get( &self, manager: &M, operator: O, operands: &[Borrowed<'_, M::Edge>], ) -> Option<M::Edge>

Shorthand for Self::get_with_numeric() without numeric operands

Source

fn add( &self, manager: &M, operator: O, operands: &[Borrowed<'_, M::Edge>], value: Borrowed<'_, M::Edge>, )

Shorthand for Self::add_with_numeric() without numeric operands

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§