pub struct ChunkIndex { /* private fields */ }Expand description
Chunk hashes for the files under one root.
Implementations§
Source§impl ChunkIndex
impl ChunkIndex
Sourcepub fn load(root: &Path) -> Self
pub fn load(root: &Path) -> Self
Load the index for root, or start empty if there is none to load.
A corrupt or truncated index is treated as absent: the cost is re- hashing, and trusting damaged hashes would be the one outcome worth avoiding.
Sourcepub fn get(
&self,
rel: &str,
size: u64,
mtime: i64,
chunk_size: u32,
) -> Option<&[[u8; 32]]>
pub fn get( &self, rel: &str, size: u64, mtime: i64, chunk_size: u32, ) -> Option<&[[u8; 32]]>
Hashes for a file, if the cache still describes it.
pub fn insert( &mut self, rel: &str, size: u64, mtime: i64, chunk_size: u32, hashes: Vec<[u8; 32]>, )
Sourcepub fn retain(&mut self, keep: &HashSet<String>)
pub fn retain(&mut self, keep: &HashSet<String>)
Forget everything not named in keep, so a long-lived index does not
accumulate entries for files that were deleted years ago.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ChunkIndex
impl RefUnwindSafe for ChunkIndex
impl Send for ChunkIndex
impl Sync for ChunkIndex
impl Unpin for ChunkIndex
impl UnsafeUnpin for ChunkIndex
impl UnwindSafe for ChunkIndex
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