Trait kdevice::cache::Cache[][src]

pub trait Cache: Sized {
    type Key: Hash + Eq + Default + Copy + Debug;
    type Value: Debug;
    type GetFut;
    type DiskReadFuture: Future<Output = Result<()>> + 'async_trait;
    type DiskWriteFuture: Future<Output = Result<()>> + 'async_trait;
    #[must_use]
    fn disk_read<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        key: &'life1 Self::Key,
        value: &'life2 mut Self::Value
    ) -> Self::DiskReadFuture
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        'life2: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn disk_write<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        key: &'life1 Self::Key,
        value: &'life2 Self::Value
    ) -> Self::DiskWriteFuture
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        'life2: 'async_trait,
        Self: 'async_trait
;
fn cache_self<'a>(
        &'a self
    ) -> &'a Spinlock<CacheData<Self::Key, Self::Value>>;
fn cache_get<'a>(&'a self, key: Self::Key, flush: bool) -> Self::GetFut; fn new_cache(
        n: usize,
        default_val: impl Fn() -> Result<Self::Value>
    ) -> Result<Spinlock<CacheData<Self::Key, Self::Value>>> { ... }
fn cache_invalidate<'a>(&'a self) { ... } }

Associated Types

type Key: Hash + Eq + Default + Copy + Debug[src]

type Value: Debug[src]

type GetFut[src]

type DiskReadFuture: Future<Output = Result<()>> + 'async_trait[src]

type DiskWriteFuture: Future<Output = Result<()>> + 'async_trait[src]

Required methods

#[must_use]
fn disk_read<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 self,
    key: &'life1 Self::Key,
    value: &'life2 mut Self::Value
) -> Self::DiskReadFuture where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 
[src]

#[must_use]
fn disk_write<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 self,
    key: &'life1 Self::Key,
    value: &'life2 Self::Value
) -> Self::DiskWriteFuture where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 
[src]

fn cache_self<'a>(&'a self) -> &'a Spinlock<CacheData<Self::Key, Self::Value>>[src]

Function used to retrieve the cache.

fn cache_get<'a>(&'a self, key: Self::Key, flush: bool) -> Self::GetFut[src]

Get a cache item by key. Won’t lock it. If key has already been in memory, this operation always succeed. If cannot reserve cache entry, returns None. Donot implement it. Instead, injected to the trait implementation by super::cache_impl.

Provided methods

fn new_cache(
    n: usize,
    default_val: impl Fn() -> Result<Self::Value>
) -> Result<Spinlock<CacheData<Self::Key, Self::Value>>>
[src]

Create a new cache with at most n in-memory cache entries.

default_val is used to generate the initial value. It should return a Result since oom may occur during generation, e.g. Box<[u8; 512]>.

Donot override this implementation.

fn cache_invalidate<'a>(&'a self)[src]

Mark all dirty entry as invalid without synchronizing with disk. May cause inconsistency! Donot implement it.

Implementors

impl Cache for FAT[src]

The inode cache.

type Key = InodeKey

type Value = Inode

fn cache_self<'a>(&'a self) -> &'a Spinlock<CacheData<Self::Key, Self::Value>>[src]

type GetFut = impl Future<Output = Result<Option<CacheEntry<'a, Self>>>>

fn cache_get<'a>(&'a self, key: Self::Key, flush: bool) -> Self::GetFut[src]

fn disk_read<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 self,
    _key: &'life1 Self::Key,
    inode: &'life2 mut Self::Value
) -> Self::DiskReadFuture where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 
[src]

fn disk_write<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 self,
    _key: &'life1 Self::Key,
    _ip: &'life2 Self::Value
) -> Self::DiskWriteFuture where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 
[src]

type DiskReadFuture = impl Future<Output = Result<()>> + 'async_trait

type DiskWriteFuture = impl Future<Output = Result<()>> + 'async_trait

impl Cache for Log[src]

The bio cache.

type Key = usize

type Value = Box<[u8; 512]>

fn cache_self<'a>(&'a self) -> &'a Spinlock<CacheData<Self::Key, Self::Value>>[src]

type GetFut = impl Future<Output = Result<Option<CacheEntry<'a, Self>>>>

fn cache_get<'a>(&'a self, key: Self::Key, flush: bool) -> Self::GetFut[src]

fn disk_read<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 self,
    key: &'life1 Self::Key,
    val: &'life2 mut Self::Value
) -> Self::DiskReadFuture where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 
[src]

fn disk_write<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 self,
    key: &'life1 Self::Key,
    val: &'life2 Self::Value
) -> Self::DiskWriteFuture where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 
[src]

type DiskReadFuture = impl Future<Output = Result<()>> + 'async_trait

type DiskWriteFuture = impl Future<Output = Result<()>> + 'async_trait