[−][src]Struct sit_core::record::OrderedFiles
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]
impl<'a, F: File> OrderedFiles<'a, F> where
F: 'a,
F::Read: 'a,
pub fn boxed(self) -> BoxedOrderedFiles<'a>
[src]
pub fn boxed(self) -> BoxedOrderedFiles<'a>
Returns a boxed version of itself
It's useful to ensure type compatibility between branches,
in one of which an intersection of differently-typed File
s
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]
impl<'a, F: File> OrderedFiles<'a, F>
pub fn hash_and<PF, F_, PC, E>(
self,
hasher: &mut dyn Hasher,
per_file: PF,
per_chunk: PC
) -> Result<(), E> where
PF: Fn(&str) -> Result<F_, E>,
PC: Fn(F_, &[u8]) -> Result<F_, E>,
E: From<Error>,
[src]
pub fn hash_and<PF, F_, PC, E>(
self,
hasher: &mut dyn Hasher,
per_file: PF,
per_chunk: PC
) -> Result<(), E> where
PF: Fn(&str) -> Result<F_, E>,
PC: Fn(F_, &[u8]) -> Result<F_, E>,
E: From<Error>,
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.
pub fn hash(self, hasher: &mut dyn Hasher) -> Result<(), Error>
[src]
pub fn hash(self, hasher: &mut dyn Hasher) -> Result<(), Error>
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]
impl<'a, I, F> From<I> for OrderedFiles<'a, (String, F::Read)> where
I: IntoIterator<Item = F>,
F: File + 'a,
impl<'a, F, S> Sub<S> for OrderedFiles<'a, F> where
F: File + 'a,
S: AsRef<str> + 'a,
[src]
impl<'a, F, S> Sub<S> for OrderedFiles<'a, F> where
F: File + 'a,
S: AsRef<str> + 'a,
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, rhs: S) -> Self::Output
[src]
fn sub(self, rhs: S) -> Self::Output
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]
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,
type Output = BoxedOrderedFiles<'a>
The resulting type after applying the +
operator.
fn add(self, rhs: OrderedFiles<'a, F2>) -> Self::Output
[src]
fn add(self, rhs: OrderedFiles<'a, F2>) -> Self::Output
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]
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>>,
type Output = BoxedOrderedFiles<'a>
The resulting type after applying the +
operator.
fn add(self, rhs: I) -> Self::Output
[src]
fn add(self, rhs: I) -> Self::Output
Performs the +
operation.
Auto Trait Implementations
impl<'a, F> Send for OrderedFiles<'a, F> where
F: Send,
impl<'a, F> Send for OrderedFiles<'a, F> where
F: Send,
impl<'a, F> Sync for OrderedFiles<'a, F> where
F: Sync,
impl<'a, F> Sync for OrderedFiles<'a, F> where
F: Sync,
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
try_from
)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
try_from
)Performs the conversion.
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 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
impl<T> Same for T
type Output = T
Should always be Self