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) -> BoxFuture<'static, Result<Load<K, V, P>>>;
fn delete(&self, hash: u64);
fn may_contains(&self, hash: u64) -> bool;
fn destroy(&self) -> BoxFuture<'static, Result<()>>;
fn wait(&self) -> BoxFuture<'static, ()>;
fn close(&self) -> BoxFuture<'static, Result<()>>;
}Expand description
Disk cache engine trait.
Required Methods§
Sourcefn filter(&self, hash: u64, estimated_size: usize) -> StorageFilterResult
fn filter(&self, hash: u64, estimated_size: usize) -> StorageFilterResult
Return if the given key can be picked by the disk cache engine.
Sourcefn enqueue(&self, piece: PieceRef<K, V, P>, estimated_size: usize)
fn enqueue(&self, piece: PieceRef<K, V, P>, estimated_size: usize)
Push a in-memory cache piece to the disk cache write queue.
Sourcefn load(&self, hash: u64) -> BoxFuture<'static, Result<Load<K, V, P>>>
fn load(&self, hash: u64) -> BoxFuture<'static, Result<Load<K, V, P>>>
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.
Sourcefn may_contains(&self, hash: u64) -> bool
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.
Sourcefn destroy(&self) -> BoxFuture<'static, Result<()>>
fn destroy(&self) -> BoxFuture<'static, Result<()>>
Delete all cached entries of the disk cache.