// Customize deserailization methods
// Several deserialize functions will call visit_byte_buf.
// We reserve the first byte to be a tag to distinguish between different callers:
// int(0), nat(1), principal(2), reserved(3), service(4), function(5)
// This is necessary for deserializing IDLValue because
// it has only one visitor and we need a way to know who called the visitor.
Customize deserailization methods
Several deserialize functions will call visit_byte_buf.
We reserve the first byte to be a tag to distinguish between different callers:
int(0), nat(1), principal(2), reserved(3), service(4), function(5)
This is necessary for deserializing IDLValue because
it has only one visitor and we need a way to know who called the visitor.
Customize deserailization methods Several deserialize functions will call visit_byte_buf . We reserve the first byte to be a tag to distinguish between different callers : int ( 0 ) nat ( 1 ) principal ( 2 ) reserved ( 3 ) service ( 4 ) function ( 5 ) This is necessary for deserializing IDLValue because it has only one visitor and we need a way to know who called the visitor .
fn deserialize_int<'a, V>(&'a mut self, visitor: V) -> Result<V::Value>
    where
        V: Visitor<'de>,
    {
        use std::convert::TryInto;
        self.unroll_type()?;
        assert!(self.expect_type == Type::Int);
        let mut bytes = vec![0u8];
        let int = match &self.wire_type {
            Type::Int => Int::decode(&mut self.input).map_err(Error::msg)?,
            Type::Nat => Int(Nat::decode(&mut self.input)
                .map_err(Error::msg)?
                .0
                .try_into()
                .map_err(Error::msg)?),
            // We already did subtype checking before deserialize, so this is unreachable code
            _ => assert!(false),
        };
        bytes.extend_from_slice(&int.0.to_signed_bytes_le());
        visitor.visit_byte_buf(bytes)
    }
fn deserialize_int < ' a , V > ( & ' a mut self , visitor : V ) -> Result < V :: Value > where V : Visitor < ' de > , { use std :: convert :: TryInto ; self . unroll_type ( ) ? ; assert ! ( self expect_type Type Int ) ; let mut bytes = vec ! [ 0u8 ] ; let int = match & self . wire_type { Type :: Int => Int :: decode ( & mut self . input ) . map_err ( Error :: msg ) ? , Type :: Nat => Int ( Nat :: decode ( & mut self . input ) . map_err ( Error :: msg ) ? . 0 . try_into ( ) . map_err ( Error :: msg ) ? ) , // We already did subtype checking before deserialize, so this is unreachable code _ => assert ! ( false ) , } ; bytes . extend_from_slice ( & int . 0 . to_signed_bytes_le ( ) ) ; visitor . visit_byte_buf ( bytes ) }
Customize deserailization methods
Several deserialize functions will call visit_byte_buf.
Customize deserailization methods Several deserialize functions will call visit_byte_buf .
&'a mut self
visitor
V