p2panda_rs/hash/error.rs
1// SPDX-License-Identifier: AGPL-3.0-or-later
2
3//! Error types for validating or creating a hash.
4use thiserror::Error;
5
6/// Error types for `Hash` struct.
7#[derive(Error, Debug)]
8pub enum HashError {
9 /// Hash string has an invalid length.
10 #[error("invalid hash length {0} bytes, expected {1} bytes")]
11 InvalidLength(usize, usize),
12
13 /// Hash string contains invalid hex characters.
14 #[error("invalid hex encoding in hash string")]
15 InvalidHexEncoding,
16
17 /// Hash is not a valid YASMF BLAKE3 hash.
18 #[error("can not decode YASMF BLAKE3 hash")]
19 DecodingFailed,
20
21 /// Internal error from `yasmf_hash` crate.
22 #[error(transparent)]
23 YasmfHashError(#[from] yasmf_hash::error::Error),
24
25 /// Internal error from `hex` crate.
26 #[error(transparent)]
27 FromHexError(#[from] hex::FromHexError),
28}