// Refer to the "Understanding deserializer lifetimes" page for information
// about the three deserialization flavors of strings in Serde.
Refer to the "Understanding deserializer lifetimes" page for information
about the three deserialization flavors of strings in Serde.
Refer to the " Understanding deserializer lifetimes " page for information about the three deserialization flavors of strings in Serde .
fn deserialize_str<V>(self, visitor: V) -> Result<V::Value>
    where
        V: Visitor<'de>,
    {
        // read tag
        let tag = self.read_tag()?;
        assert_eq!(tag, self.tag, "tag missmatch {} vs {}", tag, self.tag);
        // read len
        let len = self.read_len()?;
        // calculate actual string len
        let str_len = len - TLV_HEADER_SIZE;
        assert!(
            str_len <= self.input.len(),
            "String (tag: {:02x?}) lenght {} is longer than input data {}!",
            tag,
            str_len,
            self.input.len()
        );
        // read string
        let d: Vec<u8> = self.input.drain(0..str_len).collect();
        let s = String::from_utf8(d).unwrap();
        visitor.visit_string(s)
    }
fn deserialize_str < V > ( self , visitor : V ) -> Result < V :: Value > where V : Visitor < ' de > , { // read tag let tag = self . read_tag ( ) ? ; assert_eq ! ( tag self tag " " tag self tag ) ; // read len let len = self . read_len ( ) ? ; // calculate actual string len let str_len = len - TLV_HEADER_SIZE ; assert ! ( str_len self input len ( ) " " tag str_len self input len ( ) ) ; // read string let d : Vec < u8 > = self . input . drain ( 0 .. str_len ) . collect ( ) ; let s = String :: from_utf8 ( d ) . unwrap ( ) ; visitor . visit_string ( s ) }
Refer to the "Understanding deserializer lifetimes" page for information
about the three deserialization flavors of strings in Serde.
Refer to the " Understanding deserializer lifetimes " page for information about the three deserialization flavors of strings in Serde .
self
visitor
V