#[non_exhaustive]pub enum Bech32Error {
InvalidHrp,
OperationFailed,
UnexpectedHrp,
#[non_exhaustive] InvalidLength {
expected: usize,
got: usize,
},
}Expand description
Errors from Bech32 (BIP-173) and Bech32m (BIP-350) decoding. Variant shapes are identical in debug and release builds; no secret material (payload bytes, HRP strings) is ever carried in an error. Errors produced when decoding Bech32 (BIP-173) or Bech32m (BIP-350) strings.
Requires feature encoding-bech32.
Variant shapes are identical in debug and release builds. No input-derived strings (such as the received HRP) are ever captured — the caller already holds the input and the expected HRP.
The std::error::Error impl requires the std feature. Without it the
type still exists and still implements Display, but
it is not an Error, so ? into Box<dyn Error> and std::io::Error::other
will not compile. This is an MSRV consequence, not a policy: core::error::Error
needs Rust 1.81 and this line targets 1.70. On 0.9.x the impl is
unconditional and available in no_std.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
InvalidHrp
The Human-Readable Part (HRP) is invalid.
OperationFailed
General bech32 operation failure (malformed string or checksum mismatch).
This is where bit-conversion failures surface too: all bit conversion
happens inside CheckedHrpstring::new(), and the .byte_iter() that
follows a successful new() is infallible.
UnexpectedHrp
The decoded HRP does not match the HRP the caller required.
The received HRP is deliberately not captured — it is input-derived text. The caller passed the expected HRP and holds the input string.
#[non_exhaustive]InvalidLength
The decoded payload length does not match the target type’s length.
Fields
This variant is marked as non-exhaustive
Trait Implementations§
Source§impl Clone for Bech32Error
impl Clone for Bech32Error
Source§fn clone(&self) -> Bech32Error
fn clone(&self) -> Bech32Error
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for Bech32Error
Source§impl Debug for Bech32Error
impl Debug for Bech32Error
Source§impl Display for Bech32Error
Available on crate feature encoding-bech32 only.
impl Display for Bech32Error
encoding-bech32 only.impl Eq for Bech32Error
Source§impl Error for Bech32Error
Available on crate features encoding-bech32 and std only.
impl Error for Bech32Error
encoding-bech32 and std only.1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()