writium_cache/
dumb.rs

1use std::marker::PhantomData;
2use writium::prelude::*;
3use cache::CacheSource;
4
5const ERR_DUMB: &'static str = "Dumb cache is used, nothing is extracted.";
6
7pub struct DumbCacheSource<T: 'static + Send + Sync>(PhantomData<T>);
8impl<T: 'static + Send + Sync> DumbCacheSource<T> {
9    pub fn new() -> DumbCacheSource<T> {
10        DumbCacheSource(PhantomData)
11    }
12}
13impl<T: 'static + Send + Sync> CacheSource for DumbCacheSource<T> {
14    type Value = T;
15    fn load(&self, _id: &str, _create: bool) -> Result<T> {
16        Err(Error::internal(ERR_DUMB))
17    }
18}