#![no_std]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![forbid(unsafe_code)]
#![doc(html_logo_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo_small.png")]
#![warn(missing_docs, rust_2018_idioms)]
#[cfg(feature = "alloc")]
#[macro_use]
extern crate alloc;
#[cfg(feature = "std")]
extern crate std;
#[cfg(feature = "dev")]
#[cfg_attr(docsrs, doc(cfg(feature = "dev")))]
pub mod dev;
mod digest;
mod dyn_digest;
mod errors;
mod fixed;
mod variable;
mod xof;
pub use crate::digest::{Digest, Output};
pub use crate::errors::InvalidOutputSize;
pub use crate::fixed::{FixedOutput, FixedOutputDirty};
pub use crate::variable::{VariableOutput, VariableOutputDirty};
pub use crate::xof::{ExtendableOutput, ExtendableOutputDirty, XofReader};
pub use generic_array::{self, typenum::consts};
#[cfg(feature = "alloc")]
pub use dyn_digest::DynDigest;
use generic_array::ArrayLength;
pub trait Update {
fn update(&mut self, data: impl AsRef<[u8]>);
fn chain(mut self, data: impl AsRef<[u8]>) -> Self
where
Self: Sized,
{
self.update(data);
self
}
}
pub trait BlockInput {
type BlockSize: ArrayLength<u8>;
}
pub trait Reset {
fn reset(&mut self);
}
#[macro_export]
macro_rules! impl_write {
($hasher:ident) => {
#[cfg(feature = "std")]
impl std::io::Write for $hasher {
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
Update::update(self, buf);
Ok(buf.len())
}
fn flush(&mut self) -> std::io::Result<()> {
Ok(())
}
}
};
}