[][src]Struct bitar::ChunkIndex

pub struct ChunkIndex(_);

Index of chunks for a file.

Allows us to map between chunk hashes and source content location.

Implementations

impl ChunkIndex[src]

pub fn new_empty() -> Self[src]

Create an empty chunk index.

pub fn add_chunk(&mut self, hash: HashSum, size: usize, offsets: &[u64])[src]

Add a chunk with size and offsets to the index.

pub fn remove(&mut self, hash: &HashSum) -> Option<ChunkLocation>[src]

Remove a chunk by hash.

pub fn contains(&self, hash: &HashSum) -> bool[src]

Test if a chunk is in the index.

pub fn len(&self) -> usize[src]

Get number of chunks in the index.

pub fn is_empty(&self) -> bool[src]

Test if index is empty.

pub fn offsets<'a>(
    &'a self,
    hash: &HashSum
) -> Option<impl Iterator<Item = u64> + 'a>
[src]

Iterate source offsets of a chunk.

pub fn keys(&self) -> impl Iterator<Item = &HashSum>[src]

Iterate chunk hashes in index.

pub fn strip_chunks_already_in_place(
    &self,
    chunk_set: &mut ChunkIndex
) -> (usize, u64)
[src]

Filter the given chunk index for chunks which are already in place in self

Returns the number of chunks filtered and total size of them.

pub fn reorder_ops(&self, new_order: &ChunkIndex) -> Vec<ReorderOp>[src]

Get a description of how to transform one source file into another.

The transformation is done by reordering the chunks of a file in place trying to match the new order. Only the chunks present in both the current index and the new index will be reordered, while chunks that are not present in the current index still has to be fetched from elsewhere.

pub fn iter_chunks(&self) -> impl Iterator<Item = (&HashSum, &ChunkLocation)>[src]

Iterate all chunks in the index.

Chunks are returned in undefined order.

Trait Implementations

impl Clone for ChunkIndex[src]

impl Debug for ChunkIndex[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.