From 2fb71dd9436eb77c375af2f014a318d932108632 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Wed, 4 Oct 2023 12:24:51 +1100 Subject: [PATCH] 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. --- bitcoin/src/p2p/mod.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/bitcoin/src/p2p/mod.rs b/bitcoin/src/p2p/mod.rs index f4b7698c..f758c2ce 100644 --- a/bitcoin/src/p2p/mod.rs +++ b/bitcoin/src/p2p/mod.rs @@ -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 for Magic { } } -/// Error in creating a Network from Magic bytes. -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct UnknownMagic(Magic); - impl TryFrom 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)