Expand description
WDP (Waddling Diagnostic Protocol) Conformant Hash Implementation
This module provides hash functions that are fully conformant with the WDP specification (Parts 5 and 7).
§WDP Part 5: Compact IDs
Error codes are hashed using xxHash3 with the seed 0x000031762D706477:
- Input is normalized (trimmed and uppercased)
- Output is 5 Base62 characters
§WDP Part 7: Namespaces
Namespaces are hashed using xxHash3 with a different seed 0x31762D736E706477:
- This prevents collisions between namespace and code hashes
- Combined format:
namespace_hash-code_hash(e.g.,h4tYw2-81E9g)
§Example
use waddling_errors_hash::wdp::{
compute_wdp_hash,
compute_wdp_namespace_hash,
compute_wdp_full_id,
};
// Hash an error code (WDP Part 5)
let hash = compute_wdp_hash("E.Auth.Token.001");
assert_eq!(hash.len(), 5);
// Hash a namespace (WDP Part 7)
let ns_hash = compute_wdp_namespace_hash("auth_lib");
assert_eq!(ns_hash.len(), 5);
// Combined identifier (namespace_hash-code_hash)
let full_id = compute_wdp_full_id("auth_lib", "E.Auth.Token.001");
assert_eq!(full_id.len(), 11); // 5 + 1 + 5
assert!(full_id.contains('-'));Constants§
- WDP_
CODE_ SEED - WDP v1 seed for error code hashes (Part 5: Compact IDs)
- WDP_
NAMESPACE_ SEED - WDP v1 seed for namespace hashes (Part 7: Namespaces)
Functions§
- compute_
wdp_ full_ id - Compute a full WDP identifier:
namespace_hash-code_hash - compute_
wdp_ hash - Compute a WDP-conformant hash for an error code (Part 5: Compact IDs)
- compute_
wdp_ hash_ normalized - Compute WDP hash without normalization (for pre-normalized input)
- compute_
wdp_ namespace_ hash - Compute a WDP-conformant hash for a namespace (Part 7: Namespaces)
- const_
format_ sequence - Format a sequence number as 3-digit zero-padded string bytes
- const_
hash_ to_ base62 - Convert a u64 hash to a 5-character Base62 array (const-compatible)
- const_
wdp_ hash - Compute a WDP-conformant hash at compile time
- const_
wdp_ hash_ bytes - Compute WDP hash at compile time from a byte slice
- const_
wdp_ hash_ from_ parts - Compute WDP hash from error code parts at compile time
- normalize_
wdp_ input - Normalize input for WDP hash computation
- parse_
wdp_ full_ id - Parse a WDP full identifier into namespace hash and code hash
- verify_
wdp_ hash - Verify that a hash matches the input code (WDP-conformant)
- verify_
wdp_ namespace_ hash - Verify that a namespace hash matches the input namespace