add ErrorKind::DeserializeAnyNotSupported (#211)
This commit is contained in:
parent
d04ba007dc
commit
45e70e297e
|
|
@ -2,6 +2,8 @@
|
||||||
name = "bincode"
|
name = "bincode"
|
||||||
version = "0.8.1"
|
version = "0.8.1"
|
||||||
authors = ["Ty Overby <ty@pre-alpha.com>", "Francesco Mazzoli <f@mazzo.li>", "David Tolnay <dtolnay@gmail.com>", "Daniel Griffen"]
|
authors = ["Ty Overby <ty@pre-alpha.com>", "Francesco Mazzoli <f@mazzo.li>", "David Tolnay <dtolnay@gmail.com>", "Daniel Griffen"]
|
||||||
|
|
||||||
|
# Adding ErrorKind::DeserializeAnyNotSupported is a breaking change
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
repository = "https://github.com/TyOverby/bincode"
|
repository = "https://github.com/TyOverby/bincode"
|
||||||
|
|
|
||||||
|
|
@ -85,8 +85,7 @@ where R: BincodeRead<'de>, S: SizeLimit, E: ByteOrder {
|
||||||
fn deserialize_any<V>(self, _visitor: V) -> Result<V::Value>
|
fn deserialize_any<V>(self, _visitor: V) -> Result<V::Value>
|
||||||
where V: serde::de::Visitor<'de>,
|
where V: serde::de::Visitor<'de>,
|
||||||
{
|
{
|
||||||
let message = "bincode does not support Deserializer::deserialize_any";
|
Err(Box::new(ErrorKind::DeserializeAnyNotSupported))
|
||||||
Err(Error::custom(message))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deserialize_bool<V>(self, visitor: V) -> Result<V::Value>
|
fn deserialize_bool<V>(self, visitor: V) -> Result<V::Value>
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,9 @@ pub enum ErrorKind {
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
detail: Option<String>
|
detail: Option<String>
|
||||||
},
|
},
|
||||||
|
/// Serde has a deserialize_any method that lets the format hint to the
|
||||||
|
/// object which route to take in deserializing.
|
||||||
|
DeserializeAnyNotSupported,
|
||||||
/// If (de)serializing a message takes more than the provided size limit, this
|
/// If (de)serializing a message takes more than the provided size limit, this
|
||||||
/// error is returned.
|
/// error is returned.
|
||||||
SizeLimit,
|
SizeLimit,
|
||||||
|
|
@ -56,6 +59,7 @@ impl error::Error for ErrorKind {
|
||||||
ErrorKind::Io(ref err) => error::Error::description(err),
|
ErrorKind::Io(ref err) => error::Error::description(err),
|
||||||
ErrorKind::InvalidEncoding{desc, ..} => desc,
|
ErrorKind::InvalidEncoding{desc, ..} => desc,
|
||||||
ErrorKind::SequenceMustHaveLength => "bincode can't encode infinite sequences",
|
ErrorKind::SequenceMustHaveLength => "bincode can't encode infinite sequences",
|
||||||
|
ErrorKind::DeserializeAnyNotSupported => "bincode doesn't support serde::Deserializer::deserialize_any",
|
||||||
ErrorKind::SizeLimit => "the size limit for decoding has been reached",
|
ErrorKind::SizeLimit => "the size limit for decoding has been reached",
|
||||||
ErrorKind::Custom(ref msg) => msg,
|
ErrorKind::Custom(ref msg) => msg,
|
||||||
|
|
||||||
|
|
@ -67,6 +71,7 @@ impl error::Error for ErrorKind {
|
||||||
ErrorKind::Io(ref err) => Some(err),
|
ErrorKind::Io(ref err) => Some(err),
|
||||||
ErrorKind::InvalidEncoding{..} => None,
|
ErrorKind::InvalidEncoding{..} => None,
|
||||||
ErrorKind::SequenceMustHaveLength => None,
|
ErrorKind::SequenceMustHaveLength => None,
|
||||||
|
ErrorKind::DeserializeAnyNotSupported => None,
|
||||||
ErrorKind::SizeLimit => None,
|
ErrorKind::SizeLimit => None,
|
||||||
ErrorKind::Custom(_) => None,
|
ErrorKind::Custom(_) => None,
|
||||||
}
|
}
|
||||||
|
|
@ -92,6 +97,8 @@ impl fmt::Display for ErrorKind {
|
||||||
write!(fmt, "bincode can only encode sequences and maps that have a knowable size ahead of time."),
|
write!(fmt, "bincode can only encode sequences and maps that have a knowable size ahead of time."),
|
||||||
ErrorKind::SizeLimit =>
|
ErrorKind::SizeLimit =>
|
||||||
write!(fmt, "size limit was exceeded"),
|
write!(fmt, "size limit was exceeded"),
|
||||||
|
ErrorKind::DeserializeAnyNotSupported=>
|
||||||
|
write!(fmt, "bincode does not support the serde::Deserializer::deserialize_any method"),
|
||||||
ErrorKind::Custom(ref s) =>
|
ErrorKind::Custom(ref s) =>
|
||||||
s.fmt(fmt),
|
s.fmt(fmt),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue