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:
parent
39314ad52f
commit
2fb71dd943
|
@ -221,15 +221,6 @@ impl Magic {
|
||||||
pub fn to_bytes(self) -> [u8; 4] { self.0 }
|
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 {
|
impl FromStr for Magic {
|
||||||
type Err = ParseMagicError;
|
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 {
|
impl TryFrom<Magic> for Network {
|
||||||
type Error = UnknownMagic;
|
type Error = UnknownMagic;
|
||||||
|
|
||||||
|
@ -338,6 +325,15 @@ impl BorrowMut<[u8; 4]> for Magic {
|
||||||
fn borrow_mut(&mut self) -> &mut [u8; 4] { &mut self.0 }
|
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 {
|
impl fmt::Display for ParseMagicError {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
||||||
write_err!(f, "failed to parse {} as network magic", self.magic; self.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);
|
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 {
|
impl fmt::Display for UnknownMagic {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
||||||
write!(f, "unknown network magic {}", self.0)
|
write!(f, "unknown network magic {}", self.0)
|
||||||
|
|
Loading…
Reference in New Issue