[−][src]Struct ion_binary_rs::IonHash
Ion Hash implementation. Once the hasher is initialized you can add new values to it
and it will perform the dot operation internally. Once you added everything you want
to add just call get()
and it will provide you with a &u8 slice containing the
hash.
You can use the method digest if you want to hash only one IonValue.
use sha2::Sha256; use ion_binary_rs::{IonHash, IonValue}; use std::collections::HashMap; let mut ion_struct = HashMap::new(); ion_struct.insert("Model".to_string(), IonValue::String("CLK 350".to_string())); ion_struct.insert("Type".to_string(), IonValue::String("Sedan".to_string())); ion_struct.insert("Color".to_string(), IonValue::String("White".to_string())); ion_struct.insert( "VIN".to_string(), IonValue::String("1C4RJFAG0FC625797".to_string()), ); ion_struct.insert("Make".to_string(), IonValue::String("Mercedes".to_string())); ion_struct.insert("Year".to_string(), IonValue::Integer(2019)); let ion_value = IonValue::Struct(ion_struct); let hash = IonHash::digest::<Sha256>(&ion_value); println!("{:X?}", hash);
Implementations
impl<D: Digest> IonHash<D>
[src]
pub fn add_bytes(&mut self, value: &[u8])
[src]
Hashes the bytes and perform a dot operation with current version of the IonHash hash.
pub fn add_hashed_bytes(&mut self, value: &[u8])
[src]
Assumes that the bytes are already hashed and performs the dot operation with current version of the IonHash hash.
pub fn add_ion_value(&mut self, value: &IonValue)
[src]
Serializes and hashes the Ion Value and performs the dot operation with current version of the IonHash hash.
pub fn dot(&mut self, value: IonHash<D>) -> &mut Self
[src]
performs the dot operation with current version of the IonHash hash.
pub fn get(&self) -> &[u8]
[src]
Gets the current hash. Useful for when you need to extract the final result after several operations.
impl IonHash
[src]
pub fn new() -> IonHash
[src]
Creates an empty Ion Hash with the default hasher: Sha256
pub fn from_bytes<D: Digest>(buf: &[u8]) -> IonHash<D>
[src]
Creates a hasher with some starting bytes which will be first hashed
pub fn from_hashes_bytes<D: Digest>(buf: &[u8]) -> IonHash<D>
[src]
Creates a hasher with some starting hash
pub fn from_ion_value<D: Digest>(value: &IonValue) -> IonHash<D>
[src]
Creates a hasher with some starting Ion Value which will be first serialized and hashed
pub fn with_hasher<D: Digest>() -> IonHash<D>
[src]
Creates an empty hasher using the provided hasher
pub fn digest<D: Digest>(value: &IonValue) -> Vec<u8>
[src]
Shorthand method for hashing an Ion Value in one step.
pub fn default_digest(value: &IonValue) -> Vec<u8>
[src]
Shorthand method for hashing an Ion Value in one step. It uses the default hasher: Sha256
Trait Implementations
impl<D: Debug + Digest> Debug for IonHash<D>
[src]
impl Default for IonHash
[src]
impl<D: Digest> PartialEq<IonHash<D>> for IonHash<D>
[src]
impl<D: Digest> PartialOrd<IonHash<D>> for IonHash<D>
[src]
Auto Trait Implementations
impl<D> RefUnwindSafe for IonHash<D> where
D: RefUnwindSafe,
D: RefUnwindSafe,
impl<D> Send for IonHash<D> where
D: Send,
D: Send,
impl<D> Sync for IonHash<D> where
D: Sync,
D: Sync,
impl<D> Unpin for IonHash<D> where
D: Unpin,
D: Unpin,
impl<D> UnwindSafe for IonHash<D> where
D: UnwindSafe,
D: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,