pub struct DiskCache { /* private fields */ }Expand description
A disk cache is “perferably” a sparse file that allows snapshot blocks to be writen to disk and is checked before trying to downloading a block. The cache uses a i32 (data type that AWS uses to store a block index) index to determine if a give block has already been downloaded. This index is commited to disk every n number of writes (see .with_commit_frequency()).
Implementations§
Source§impl DiskCache
impl DiskCache
pub fn from_path(path: impl AsRef<Path>) -> Result<Self, Error>
pub fn with_commit_frequency(self, commit_frequency: u32) -> Self
Sourcepub fn read_block(
&mut self,
index: i32,
block_size: usize,
) -> Result<Option<Vec<u8>>, Error>
pub fn read_block( &mut self, index: i32, block_size: usize, ) -> Result<Option<Vec<u8>>, Error>
Given an index and the block size, read a block from the cache
Sourcepub fn write_block(&mut self, index: i32, block: &[u8]) -> Result<bool, Error>
pub fn write_block(&mut self, index: i32, block: &[u8]) -> Result<bool, Error>
Write a block to the cache. If we have seen this block, ignore it. Return false if it has not been seen before, true if it has
Sourcepub fn index_file_location(&self) -> PathBuf
pub fn index_file_location(&self) -> PathBuf
Get the index location for this cache
Auto Trait Implementations§
impl Freeze for DiskCache
impl RefUnwindSafe for DiskCache
impl Send for DiskCache
impl Sync for DiskCache
impl Unpin for DiskCache
impl UnwindSafe for DiskCache
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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