Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use crate::*;

pub trait ByteProvider: Sized + std::fmt::Display
{
    fn compute<T: Read + ?Sized>(input: &mut T, salt: &salt::Salt, provided: &mut usize) -> Result<Self, error::Error>;
    fn bytes(&self) -> &[u8];
}


pub fn compute<T: Read + ?Sized, P: ByteProvider>(input: &mut T, salt: salt::Salt) -> Result<(usize, P), error::Error>
{
    let mut output = 0usize;
    let this = P::compute(input, &salt, &mut output)?;
    Ok((output, this))
}