Move NetworkValidationError within file

Done in preparation for adding the `NetworkValidationError` as a variant
of `ParseError`.

Move the `NetworkValidationError` type to beneath `ParseError`.

Code move only, no other changes.
This commit is contained in:
Tobin C. Harding 2024-03-19 09:08:54 +11:00
parent c211e7be78
commit d5c52618a9
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 20 additions and 20 deletions

View File

@ -9,26 +9,6 @@ use crate::blockdata::script::{witness_program, witness_version};
use crate::prelude::*;
use crate::Network;
/// Address's network differs from required one.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct NetworkValidationError {
/// Network that was required.
pub(crate) required: Network,
/// The address itself.
pub(crate) address: Address<NetworkUnchecked>,
}
impl fmt::Display for NetworkValidationError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "address ")?;
fmt::Display::fmt(&self.address.0, f)?;
write!(f, " is not valid on {}", self.required)
}
}
#[cfg(feature = "std")]
impl std::error::Error for NetworkValidationError {}
/// Error while generating address from script.
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
@ -228,6 +208,26 @@ impl std::error::Error for UnknownHrpError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { None }
}
/// Address's network differs from required one.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct NetworkValidationError {
/// Network that was required.
pub(crate) required: Network,
/// The address itself.
pub(crate) address: Address<NetworkUnchecked>,
}
impl fmt::Display for NetworkValidationError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "address ")?;
fmt::Display::fmt(&self.address.0, f)?;
write!(f, " is not valid on {}", self.required)
}
}
#[cfg(feature = "std")]
impl std::error::Error for NetworkValidationError {}
/// Decoded base58 data was an invalid length.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct InvalidBase58PayloadLengthError {