pub trait NameHashable {
// Provided method
fn hash_name(name: &str) -> String { ... }
}Expand description
Trait for types that can generate a hashed name according to TAIP-12
Provided Methods§
Sourcefn hash_name(name: &str) -> String
fn hash_name(name: &str) -> String
Generate a SHA-256 hash of the name according to TAIP-12 normalization rules
The normalization process:
- Remove all whitespace characters
- Convert to uppercase
- Encode as UTF-8
- Hash with SHA-256
- Return as lowercase hex string
§Arguments
name- The name to hash (can be a person’s full name or organization name)
§Returns
A 64-character lowercase hex string representing the SHA-256 hash
§Example
use tap_msg::utils::name_hash::NameHashable;
struct Person;
impl NameHashable for Person {}
let hash = Person::hash_name("Alice Lee");
assert_eq!(hash, "b117f44426c9670da91b563db728cd0bc8bafa7d1a6bb5e764d1aad2ca25032e");Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.