use thiserror::Error;
use crate::xof::blake3::XOFError;
pub trait Stream {
fn xor_key_stream(&mut self, dst: &mut [u8], src: &[u8]) -> Result<(), StreamError>;
}
impl<S: Stream + ?Sized> Stream for Box<S> {
fn xor_key_stream(&mut self, dst: &mut [u8], src: &[u8]) -> Result<(), StreamError> {
self.as_mut().xor_key_stream(dst, src)
}
}
#[derive(Error, Debug)]
pub enum StreamError {
#[error("io error")]
IoError(#[from] std::io::Error),
#[error("XOF error")]
XOFError(#[from] XOFError),
#[error("mismatched buffer lengths")]
WrongBufferLengths,
#[error("all readers failed")]
ReadersFailure,
}