pub struct CachedBackend {
be: Arc<dyn WriteBackend>,
cache: Cache,
}
Expand description
Backend that caches data.
This backend caches data in a directory. It can be used to cache data from a remote backend.
§Type Parameters
BE
- The backend to cache.
Fields§
§be: Arc<dyn WriteBackend>
The backend to cache.
cache: Cache
The cache.
Implementations§
Source§impl CachedBackend
impl CachedBackend
Sourcepub fn new_cache(
be: Arc<dyn WriteBackend>,
cache: Cache,
) -> Arc<dyn WriteBackend>
pub fn new_cache( be: Arc<dyn WriteBackend>, cache: Cache, ) -> Arc<dyn WriteBackend>
Trait Implementations§
Source§impl Clone for CachedBackend
impl Clone for CachedBackend
Source§fn clone(&self) -> CachedBackend
fn clone(&self) -> CachedBackend
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for CachedBackend
impl Debug for CachedBackend
Source§impl ReadBackend for CachedBackend
impl ReadBackend for CachedBackend
Source§fn list_with_size(&self, tpe: FileType) -> RusticResult<Vec<(Id, u32)>>
fn list_with_size(&self, tpe: FileType) -> RusticResult<Vec<(Id, u32)>>
Source§fn read_partial(
&self,
tpe: FileType,
id: &Id,
cacheable: bool,
offset: u32,
length: u32,
) -> RusticResult<Bytes>
fn read_partial( &self, tpe: FileType, id: &Id, cacheable: bool, offset: u32, length: u32, ) -> RusticResult<Bytes>
Source§fn needs_warm_up(&self) -> bool
fn needs_warm_up(&self) -> bool
Specify if the backend needs a warming-up of files before accessing them.
Source§impl WriteBackend for CachedBackend
impl WriteBackend for CachedBackend
Source§fn create(&self) -> RusticResult<()>
fn create(&self) -> RusticResult<()>
Creates the backend.
Source§fn write_bytes(
&self,
tpe: FileType,
id: &Id,
cacheable: bool,
buf: Bytes,
) -> RusticResult<()>
fn write_bytes( &self, tpe: FileType, id: &Id, cacheable: bool, buf: Bytes, ) -> RusticResult<()>
Writes the given data to the given file.
If the file is cacheable, it will also be written to the cache.
§Arguments
tpe
- The type of the file.id
- The id of the file.cacheable
- Whether the file is cacheable.buf
- The data to write.
Auto Trait Implementations§
impl Freeze for CachedBackend
impl !RefUnwindSafe for CachedBackend
impl Send for CachedBackend
impl Sync for CachedBackend
impl Unpin for CachedBackend
impl !UnwindSafe for CachedBackend
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more