Struct ion_binary_rs::IonHash[][src]

pub struct IonHash<D: Digest = Sha256> { /* fields omitted */ }
Expand description

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

Hashes the bytes and perform a dot operation with current version of the IonHash hash.

Assumes that the bytes are already hashed and performs the dot operation with current version of the IonHash hash.

Serializes and hashes the Ion Value and performs the dot operation with current version of the IonHash hash.

performs the dot operation with current version of the IonHash hash.

Gets the current hash. Useful for when you need to extract the final result after several operations.

Creates an empty Ion Hash with the default hasher: Sha256

Creates a hasher with some starting bytes which will be first hashed

Creates a hasher with some starting hash

Creates a hasher with some starting Ion Value which will be first serialized and hashed

Creates an empty hasher using the provided hasher

Shorthand method for hashing an Ion Value in one step.

Shorthand method for hashing an Ion Value in one step. It uses the default hasher: Sha256

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.