Replace serde error with the io error.
This commit is contained in:
parent
c1ff953b25
commit
5771841144
|
@ -106,12 +106,15 @@ macro_rules! user_enum {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::std::str::FromStr for $name {
|
impl ::std::str::FromStr for $name {
|
||||||
type Err = ::serde::de::value::Error;
|
type Err = ::std::io::Error;
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
match s {
|
match s {
|
||||||
$($txt => Ok($name::$elem)),*,
|
$($txt => Ok($name::$elem)),*,
|
||||||
_ => Err(::serde::de::Error::syntax(stringify!(s)))
|
_ => Err(::std::io::Error::new(
|
||||||
|
::std::io::ErrorKind::InvalidInput,
|
||||||
|
format!("Unknown network (type {})", s),
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,8 +90,8 @@ mod tests {
|
||||||
assert_eq!(Network::Bitcoin.to_string(), "bitcoin");
|
assert_eq!(Network::Bitcoin.to_string(), "bitcoin");
|
||||||
assert_eq!(Network::Testnet.to_string(), "testnet");
|
assert_eq!(Network::Testnet.to_string(), "testnet");
|
||||||
|
|
||||||
assert_eq!("bitcoin".parse(), Ok(Network::Bitcoin));
|
assert_eq!("bitcoin".parse::<Network>().unwrap(), Network::Bitcoin);
|
||||||
assert_eq!("testnet".parse(), Ok(Network::Testnet));
|
assert_eq!("testnet".parse::<Network>().unwrap(), Network::Testnet);
|
||||||
assert!("fakenet".parse::<Network>().is_err());
|
assert!("fakenet".parse::<Network>().is_err());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue