Remove unused address::Error type

This commit is contained in:
Tobin C. Harding 2024-02-27 11:10:03 +11:00
parent a92dc9c35c
commit 7e2a81d03b
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
2 changed files with 1 additions and 43 deletions

View File

@ -29,48 +29,6 @@ impl fmt::Display for NetworkValidationError {
#[cfg(feature = "std")] #[cfg(feature = "std")]
impl std::error::Error for NetworkValidationError {} impl std::error::Error for NetworkValidationError {}
/// Address error.
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum Error {
/// Address's network differs from required one.
NetworkValidation {
/// Network that was required.
required: Network,
/// The address itself
address: Address<NetworkUnchecked>,
},
/// Unknown hrp for current bitcoin networks (in bech32 address).
UnknownHrp(UnknownHrpError),
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use Error::*;
match *self {
NetworkValidation { required, ref address } => {
write!(f, "address ")?;
fmt::Display::fmt(&address.0, f)?;
write!(f, " is not valid on {}", required)
}
Error::UnknownHrp(ref e) => write_err!(f, "unknown hrp"; e),
}
}
}
#[cfg(feature = "std")]
impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
use Error::*;
match *self {
UnknownHrp(ref e) => Some(e),
NetworkValidation { .. } => None,
}
}
}
/// Error while generating address from script. /// Error while generating address from script.
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] #[non_exhaustive]

View File

@ -55,7 +55,7 @@ use self::error::P2shError;
#[rustfmt::skip] // Keep public re-exports separate. #[rustfmt::skip] // Keep public re-exports separate.
#[doc(inline)] #[doc(inline)]
pub use self::{ pub use self::{
error::{Error, NetworkValidationError, ParseError, UnknownAddressTypeError, UnknownHrpError, FromScriptError, }, error::{NetworkValidationError, ParseError, UnknownAddressTypeError, UnknownHrpError, FromScriptError, },
}; };
/// The different types of addresses. /// The different types of addresses.