Move p2p error types to bottom of file

Move the p2p error types to the bottom of the file next to the various
impls for these types.

Code move only, no other changes.
This commit is contained in:
Tobin C. Harding 2023-10-04 12:24:51 +11:00
parent 39314ad52f
commit 2fb71dd943
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 13 additions and 13 deletions

View File

@ -221,15 +221,6 @@ impl Magic {
pub fn to_bytes(self) -> [u8; 4] { self.0 }
}
/// An error in parsing magic bytes.
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct ParseMagicError {
/// The error that occurred when parsing the string.
error: hex::HexToArrayError,
/// The byte string that failed to parse.
magic: String,
}
impl FromStr for Magic {
type Err = ParseMagicError;
@ -253,10 +244,6 @@ impl From<Network> for Magic {
}
}
/// Error in creating a Network from Magic bytes.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct UnknownMagic(Magic);
impl TryFrom<Magic> for Network {
type Error = UnknownMagic;
@ -338,6 +325,15 @@ impl BorrowMut<[u8; 4]> for Magic {
fn borrow_mut(&mut self) -> &mut [u8; 4] { &mut self.0 }
}
/// An error in parsing magic bytes.
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct ParseMagicError {
/// The error that occurred when parsing the string.
error: hex::HexToArrayError,
/// The byte string that failed to parse.
magic: String,
}
impl fmt::Display for ParseMagicError {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write_err!(f, "failed to parse {} as network magic", self.magic; self.error)
@ -345,6 +341,10 @@ impl fmt::Display for ParseMagicError {
}
impl_std_error!(ParseMagicError, error);
/// Error in creating a Network from Magic bytes.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct UnknownMagic(Magic);
impl fmt::Display for UnknownMagic {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(f, "unknown network magic {}", self.0)