use digest::{self, FixedOutput, Reset, Update};
use crate::element::Element;
use crate::IonResult;
use element_hasher::ElementHasher;
mod element_hasher;
mod representation;
mod type_qualifier;
#[cfg(feature = "experimental-ion-hash")]
use digest::Output;
#[cfg(feature = "experimental-ion-hash")]
use sha2::Sha256;
#[cfg(feature = "experimental-ion-hash")]
pub fn sha256(elem: &Element) -> IonResult<Output<Sha256>> {
Sha256::hash_element(elem)
}
struct Markers;
impl Markers {
const B: u8 = 0x0B;
const E: u8 = 0x0E;
const ESC: u8 = 0x0C;
}
pub trait IonHasher {
type Output;
fn hash_element(elem: &Element) -> IonResult<Self::Output>;
}
impl<D> IonHasher for D
where
D: Update + FixedOutput + Reset + Clone + Default,
{
type Output = digest::Output<D>;
fn hash_element(elem: &Element) -> IonResult<Self::Output> {
ElementHasher::new(D::default()).hash_element(elem)
}
}