mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-05-29 10:41:21 +00:00
multiaddr: future-proof error type (#506)
This commit is contained in:
parent
3f3d81cc95
commit
b61d9faece
@ -15,7 +15,9 @@ pub enum Error {
|
|||||||
InvalidUvar(decode::Error),
|
InvalidUvar(decode::Error),
|
||||||
ParsingError(Box<dyn error::Error + Send + Sync>),
|
ParsingError(Box<dyn error::Error + Send + Sync>),
|
||||||
UnknownProtocolId(u32),
|
UnknownProtocolId(u32),
|
||||||
UnknownProtocolString
|
UnknownProtocolString,
|
||||||
|
#[doc(hidden)]
|
||||||
|
__Nonexhaustive
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for Error {
|
impl fmt::Display for Error {
|
||||||
@ -27,7 +29,8 @@ impl fmt::Display for Error {
|
|||||||
Error::InvalidUvar(e) => write!(f, "failed to decode unsigned varint: {}", e),
|
Error::InvalidUvar(e) => write!(f, "failed to decode unsigned varint: {}", e),
|
||||||
Error::ParsingError(e) => write!(f, "failed to parse: {}", e),
|
Error::ParsingError(e) => write!(f, "failed to parse: {}", e),
|
||||||
Error::UnknownProtocolId(id) => write!(f, "unknown protocol id: {}", id),
|
Error::UnknownProtocolId(id) => write!(f, "unknown protocol id: {}", id),
|
||||||
Error::UnknownProtocolString => f.write_str("unknown protocol string")
|
Error::UnknownProtocolString => f.write_str("unknown protocol string"),
|
||||||
|
Error::__Nonexhaustive => f.write_str("__Nonexhaustive")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ use std::{
|
|||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
convert::From,
|
convert::From,
|
||||||
fmt,
|
fmt,
|
||||||
io::{self, Cursor, Write},
|
io::{Cursor, Write},
|
||||||
net::{Ipv4Addr, Ipv6Addr},
|
net::{Ipv4Addr, Ipv6Addr},
|
||||||
str::{self, FromStr}
|
str::{self, FromStr}
|
||||||
};
|
};
|
||||||
@ -232,7 +232,7 @@ impl<'a> Protocol<'a> {
|
|||||||
|
|
||||||
/// Encode this protocol by writing its binary representation into
|
/// Encode this protocol by writing its binary representation into
|
||||||
/// the given `Write` impl.
|
/// the given `Write` impl.
|
||||||
pub fn write_bytes<W: Write>(&self, w: &mut W) -> io::Result<()> {
|
pub fn write_bytes<W: Write>(&self, w: &mut W) -> Result<()> {
|
||||||
let mut buf = encode::u32_buffer();
|
let mut buf = encode::u32_buffer();
|
||||||
match self {
|
match self {
|
||||||
Protocol::Ip4(addr) => {
|
Protocol::Ip4(addr) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user