Skip to main content

parse_hash_arg

Function parse_hash_arg 

Source
pub fn parse_hash_arg(hex: &str) -> Result<Hash, ErrorObjectOwned>
Expand description

Decode a 64-character hex BLAKE3 hash into a Hash.

Goes through alloy::primitives::hex::decode (case-insensitive, 0x/0X-prefix-tolerant) rather than Hash::from_str so operators may paste a 0x-prefixed hash and get a uniform INVALID_PARAMS error on malformed input. (The leaf Hash’s own FromStr is panic-free since #578 — unlike the old iroh-blobs Hash::from_str which fell through to a base32 decoder that panicked on a wrong-size output buffer — but it does not accept a 0x prefix, so the alloy path is kept for the operator ergonomics.)

§Errors

Returns an ErrorObjectOwned with INVALID_PARAMS_CODE when the input is not valid hex or doesn’t decode to exactly 32 bytes.