Skip to main content

Engine

Trait Engine 

Source
pub trait Engine<K, V, P>:
    Send
    + Sync
    + 'static
    + Debug
    + Any{
    // Required methods
    fn device(&self) -> &Arc<dyn Device>;
    fn filter(&self, hash: u64, estimated_size: usize) -> StorageFilterResult;
    fn enqueue(&self, piece: PieceRef<K, V, P>, estimated_size: usize);
    fn load(
        &self,
        hash: u64,
    ) -> Pin<Box<dyn Future<Output = Result<Load<K, V, P>, Error>> + Send>>;
    fn delete(&self, hash: u64);
    fn may_contains(&self, hash: u64) -> bool;
    fn destroy(&self) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>>;
    fn wait(&self) -> Pin<Box<dyn Future<Output = ()> + Send>>;
    fn close(&self) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>>;
}
Expand description

Disk cache engine trait.

Required Methods§

Source

fn device(&self) -> &Arc<dyn Device>

Get the device used by this disk cache engine.

Source

fn filter(&self, hash: u64, estimated_size: usize) -> StorageFilterResult

Return if the given key can be picked by the disk cache engine.

Source

fn enqueue(&self, piece: PieceRef<K, V, P>, estimated_size: usize)

Push a in-memory cache piece to the disk cache write queue.

Source

fn load( &self, hash: u64, ) -> Pin<Box<dyn Future<Output = Result<Load<K, V, P>, Error>> + Send>>

Load a cache entry from the disk cache.

load may return a false-positive result on entry key hash collision. It’s the caller’s responsibility to check if the returned key matches the given key.

Source

fn delete(&self, hash: u64)

Delete the cache entry with the given key from the disk cache.

Source

fn may_contains(&self, hash: u64) -> bool

Check if the disk cache contains a cached entry with the given key.

contains may return a false-positive result if there is a hash collision with the given key.

Source

fn destroy(&self) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>>

Delete all cached entries of the disk cache.

Source

fn wait(&self) -> Pin<Box<dyn Future<Output = ()> + Send>>

Wait for the ongoing flush and reclaim tasks to finish.

Source

fn close(&self) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>>

Close the disk cache gracefully.

close will wait for all ongoing flush and reclaim tasks to finish.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§