Support deserializing ByteBuf from string

This commit is contained in:
David Tolnay
2016-12-23 23:17:42 -05:00
parent 2c984980a0
commit 871fb5adee
3 changed files with 54 additions and 156 deletions
+13 -1
View File
@@ -208,7 +208,7 @@ mod bytebuf {
fn visit_bytes<E>(&mut self, v: &[u8]) -> Result<ByteBuf, E>
where E: de::Error,
{
self.visit_byte_buf(v.to_vec())
Ok(ByteBuf::from(v))
}
#[inline]
@@ -217,6 +217,18 @@ mod bytebuf {
{
Ok(ByteBuf::from(v))
}
fn visit_str<E>(&mut self, v: &str) -> Result<ByteBuf, E>
where E: de::Error,
{
Ok(ByteBuf::from(v))
}
fn visit_string<E>(&mut self, v: String) -> Result<ByteBuf, E>
where E: de::Error,
{
Ok(ByteBuf::from(v))
}
}
impl de::Deserialize for ByteBuf {