diff --git a/cbor_smol/de/index.html b/cbor_smol/de/index.html index e950699..f1d1fd2 100644 --- a/cbor_smol/de/index.html +++ b/cbor_smol/de/index.html @@ -1,3 +1,3 @@ -cbor_smol::de - Rust

Module cbor_smol::de

source ·

Structs§

  • A structure for deserializing a cbor-smol message.

Functions§

  • Deserialize a message of type T from a byte slice. The unused portion (if any) +cbor_smol::de - Rust

    Module cbor_smol::de

    source ·

    Structs§

    • A structure for deserializing a cbor-smol message.

    Functions§

    • Deserialize a message of type T from a byte slice. The unused portion (if any) of the byte slice is returned for further usage
    • Deserialize a message of type T from a byte slice. The unused portion (if any) of the byte slice is returned for further usage
    \ No newline at end of file diff --git a/cbor_smol/de/struct.Deserializer.html b/cbor_smol/de/struct.Deserializer.html index 5319d2f..5a7a3c1 100644 --- a/cbor_smol/de/struct.Deserializer.html +++ b/cbor_smol/de/struct.Deserializer.html @@ -1,6 +1,6 @@ Deserializer in cbor_smol::de - Rust

    Struct cbor_smol::de::Deserializer

    source ·
    pub struct Deserializer<'de> { /* private fields */ }
    Expand description

    A structure for deserializing a cbor-smol message.

    Implementations§

    source§

    impl<'de> Deserializer<'de>

    source

    pub fn from_bytes(input: &'de [u8]) -> Self

    Obtain a Deserializer from a slice of bytes

    -

    Trait Implementations§

    source§

    impl<'de, 'a> Deserializer<'de> for &'a mut Deserializer<'de>

    §

    type Error = Error

    The error type that can be returned if some error occurs during +

    Trait Implementations§

    source§

    impl<'de, 'a> Deserializer<'de> for &'a mut Deserializer<'de>

    §

    type Error = Error

    The error type that can be returned if some error occurs during deserialization.
    source§

    fn deserialize_any<V>(self, _visitor: V) -> Result<V::Value>
    where V: Visitor<'de>,

    Require the Deserializer to figure out how to drive the visitor based on what data type is in the input. Read more
    source§

    fn deserialize_bool<V>(self, visitor: V) -> Result<V::Value>
    where @@ -66,9 +66,9 @@ visitor: V, ) -> Result<V::Value>
    where V: Visitor<'de>,

    Hint that the Deserialize type is expecting an enum value with a -particular name and possible variants.
    source§

    fn deserialize_identifier<V>(self, visitor: V) -> Result<V::Value>
    where +particular name and possible variants.

    source§

    fn deserialize_identifier<V>(self, visitor: V) -> Result<V::Value>
    where V: Visitor<'de>,

    Hint that the Deserialize type is expecting the name of a struct -field or the discriminant of an enum variant.
    source§

    fn deserialize_ignored_any<V>(self, visitor: V) -> Result<V::Value>
    where +field or the discriminant of an enum variant.

    source§

    fn deserialize_ignored_any<V>(self, visitor: V) -> Result<V::Value>
    where V: Visitor<'de>,

    Hint that the Deserialize type needs to deserialize a value whose type doesn’t matter because it is ignored. Read more
    source§

    fn deserialize_i128<V>( self, diff --git a/src/cbor_smol/de.rs.html b/src/cbor_smol/de.rs.html index a57a948..719d8fe 100644 --- a/src/cbor_smol/de.rs.html +++ b/src/cbor_smol/de.rs.html @@ -1281,6 +1281,19 @@ 1281 1282 1283 +1284 +1285 +1286 +1287 +1288 +1289 +1290 +1291 +1292 +1293 +1294 +1295 +1296

    use serde::Deserialize;
     
     use serde::de::IntoDeserializer;
    @@ -2089,7 +2102,20 @@
         where
             V: Visitor<'de>,
         {
    -        self.deserialize_str(visitor)
    +        let major = self.peek_major()?;
    +        match major {
    +            MAJOR_BYTES | MAJOR_STR => {
    +                // Rust identifiers are always valid UTF-8 so we can assume that bytes are
    +                // UTF-8-encoded strings.  This has the benefit that we only need a mapping from
    +                // strings to fields (and the mapping from bytes to fields can be optimized out).
    +                let length = self.raw_deserialize_u32(major)? as usize;
    +                let bytes: &'de [u8] = self.try_take_n(length)?;
    +                let string_slice = core::str::from_utf8(bytes).map_err(|_| Error::DeserializeBadUtf8)?;
    +                visitor.visit_borrowed_str(string_slice)
    +            }
    +            MAJOR_POSINT => self.deserialize_u64(visitor),
    +            _ => Err(Error::DeserializeBadMajor),
    +        }
         }
     
         fn deserialize_ignored_any<V>(self, visitor: V) -> Result<V::Value>