[][src]Struct sit_core::record::OrderedFiles

pub struct OrderedFiles<'a, F: File>(_, _);

A collection of always ordered files

With limited ways to construct this structure, it's always ensured to have all its files sorted as required by SIT for deterministic hashing.

Methods

impl<'a, F: File> OrderedFiles<'a, F> where
    F: 'a,
    F::Read: 'a, 
[src]

Returns a boxed version of itself

It's useful to ensure type compatibility between branches, in one of which an intersection of differently-typed Files were ordered together.

extern crate sit_core;

use std::io::Cursor;
use sit_core::record::{BoxedOrderedFiles, OrderedFiles};

let files: OrderedFiles<_> = vec![("file", &b"hello"[..])].into();
let extra: OrderedFiles<_> =  vec![("file", Cursor::new(String::from("world")))].into();

let some_condition = true;

let all_files = if some_condition {
   files + extra
} else {
   files.boxed()
};

impl<'a, F: File> OrderedFiles<'a, F>
[src]

Deterministically hashes all ordered files and allows to process them as well

For every file, it will call per_file(file_name) and use the returned positive value (from inside of Ok(f_)) to call per_chunk(f_, chunk) on every chunk of read data.

This method's primary motivation is to allow hashing and saving files at the same time, to avoid re-reading them to accomplish both of the operations. By itself, however, this function doesn't do anything in term of saving files (or any other functionality), that is responsibility of per_file and per_chunk callbacks.

Deterministically hashes all ordered files

Trait Implementations

impl<'a, I, F> From<I> for OrderedFiles<'a, (String, F::Read)> where
    I: IntoIterator<Item = F>,
    F: File + 'a, 
[src]

Performs the conversion.

impl<'a, F, S> Sub<S> for OrderedFiles<'a, F> where
    F: File + 'a,
    S: AsRef<str> + 'a, 
[src]

The resulting type after applying the - operator.

Performs the - operation.

impl<'a, F1, F2> Add<OrderedFiles<'a, F2>> for OrderedFiles<'a, F1> where
    F1: File + 'a,
    F2: File + 'a,
    F1::Read: 'a,
    F2::Read: 'a, 
[src]

The resulting type after applying the + operator.

Performs the + operation.

impl<'a, F1, F2, I> Add<I> for OrderedFiles<'a, F1> where
    F1: File + 'a,
    F2: File + 'a,
    F1::Read: 'a,
    F2::Read: 'a,
    I: IntoIterator<Item = OrderedFiles<'a, F2>>, 
[src]

The resulting type after applying the + operator.

Performs the + operation.

Auto Trait Implementations

impl<'a, F> Send for OrderedFiles<'a, F> where
    F: Send

impl<'a, F> Sync for OrderedFiles<'a, F> where
    F: Sync

Blanket Implementations

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

Performs the conversion.

impl<T> From for T
[src]

Performs the conversion.

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

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

Immutably borrows from an owned value. Read more

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

Mutably borrows from an owned value. Read more

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

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

🔬 This is a nightly-only experimental API. (get_type_id)

this method will likely be replaced by an associated static

Gets the TypeId of self. Read more

impl<T> Same for T

Should always be Self