ckb_fixed_hash_core/
error.rs

1//! Conversion errors.
2
3use thiserror::Error;
4
5/// The associated error of [`FromStr`] which can be returned from parsing a string.
6///
7/// [`FromStr`]: https://doc.rust-lang.org/std/str/trait.FromStr.html#associatedtype.Err
8#[derive(Error, Debug, PartialEq, Eq)]
9pub enum FromStrError {
10    /// Invalid character.
11    #[error("Invalid character code `{chr}` at {idx}")]
12    InvalidCharacter {
13        /// The value of the invalid character.
14        chr: u8,
15        /// The index of the invalid character.
16        idx: usize,
17    },
18    /// Invalid length.
19    #[error("Invalid length: {0}")]
20    InvalidLength(usize),
21}
22
23/// The error which can be returned when convert a byte slice back into a Hash.
24#[derive(Error, Debug, PartialEq, Eq)]
25pub enum FromSliceError {
26    /// Invalid length.
27    #[error("Invalid length: {0}")]
28    InvalidLength(usize),
29}