fn deserialize(&mut self, payload: &[u8]) -> Result<Deserialization, DeserializeError> {
        crate::utils::check_message_buffer(payload)?;

        let mut buf = Cursor::from_slice(payload);
        let auth_key_id = i64::deserialize(&mut buf)?;
        if auth_key_id != 0 {
            return Err(DeserializeError::BadAuthKey {
                got: auth_key_id,
                expected: 0,
            });
        }

        let msg_id = i64::deserialize(&mut buf)?;
        // We can't validate it's close to our system time because our sytem
        // time may be wrong at this point (it only matters once encrypted
        // communication begins). However, we can validate the following:
        //
        // > server message identifiers modulo 4 yield 1 if
        // > the message is a response to a client message
        // https://core.telegram.org/mtproto/description#message-identifier-msg-id
        if msg_id <= 0 || (msg_id % 4) != 1 {
            return Err(DeserializeError::BadMessageId { got: msg_id });
        }

        let len = i32::deserialize(&mut buf)?;
        if len <= 0 {
            return Err(DeserializeError::NegativeMessageLength { got: len });
        }
        if (20 + len) as usize > payload.len() {
            return Err(DeserializeError::TooLongMessageLength {
                got: len as usize,
                max_length: payload.len() - 20,
            });
        }

        Ok(Deserialization {
            rpc_results: vec![(MsgId(0), Ok(payload[20..20 + len as usize].into()))],
            updates: Vec::new(),
        })
    }
/// Validates that the returned data is a correct plain message, and
/// if it is, the method returns the inner contents of the message.
///
/// [`serialize_plain_message`]: #method.serialize_plain_message
Validates that the returned data is a correct plain message, and
if it is, the method returns the inner contents of the message.


Validates that the returned data is a correct plain message and if it is the method returns the inner contents of the message .
fn deserialize(&mut self, payload: &[u8]) -> Result<Deserialization, DeserializeError> {
        crate::utils::check_message_buffer(payload)?;
        let mut buf = Cursor::from_slice(payload);
        let auth_key_id = i64::deserialize(&mut buf)?;
        if auth_key_id != 0 {
            return Err(DeserializeError::BadAuthKey {
                got: auth_key_id,
                expected: 0,
            });
        }
        let msg_id = i64::deserialize(&mut buf)?;
        // We can't validate it's close to our system time because our sytem
        // time may be wrong at this point (it only matters once encrypted
        // communication begins). However, we can validate the following:
        //
        // > server message identifiers modulo 4 yield 1 if
        // > the message is a response to a client message
        // https://core.telegram.org/mtproto/description#message-identifier-msg-id
        if msg_id <= 0 || (msg_id % 4) != 1 {
            return Err(DeserializeError::BadMessageId { got: msg_id });
        }
        let len = i32::deserialize(&mut buf)?;
        if len <= 0 {
            return Err(DeserializeError::NegativeMessageLength { got: len });
        }
        if (20 + len) as usize > payload.len() {
            return Err(DeserializeError::TooLongMessageLength {
                got: len as usize,
                max_length: payload.len() - 20,
            });
        }
        Ok(Deserialization {
            rpc_results: vec![(MsgId(0), Ok(payload[20..20 + len as usize].into()))],
            updates: Vec::new(),
        })
    }
fn deserialize ( & mut self , payload : & [ u8 ] ) -> Result < Deserialization , DeserializeError > { crate :: utils :: check_message_buffer ( payload ) ? ; let mut buf = Cursor :: from_slice ( payload ) ; let auth_key_id = i64 :: deserialize ( & mut buf ) ? ; if auth_key_id != 0 { return Err ( DeserializeError :: BadAuthKey { got : auth_key_id , expected : 0 , } ) ; } let msg_id = i64 :: deserialize ( & mut buf ) ? ; // We can't validate it's close to our system time because our sytem // time may be wrong at this point (it only matters once encrypted // communication begins). However, we can validate the following: // // > server message identifiers modulo 4 yield 1 if // > the message is a response to a client message // https://core.telegram.org/mtproto/description#message-identifier-msg-id if msg_id <= 0 || ( msg_id % 4 ) != 1 { return Err ( DeserializeError :: BadMessageId { got : msg_id } ) ; } let len = i32 :: deserialize ( & mut buf ) ? ; if len <= 0 { return Err ( DeserializeError :: NegativeMessageLength { got : len } ) ; } if ( 20 + len ) as usize > payload . len ( ) { return Err ( DeserializeError :: TooLongMessageLength { got : len as usize , max_length : payload . len ( ) - 20 , } ) ; } Ok ( Deserialization { rpc_results : vec ! [ ( MsgId ( 0 ) Ok ( payload [ 20 20 len as usize ] into ( ) ) ) ] , updates : Vec :: new ( ) , } ) }
Validates that the returned data is a correct plain message, and
if it is, the method returns the inner contents of the message.
Validates that the returned data is a correct plain message and if it is the method returns the inner contents of the message .
&mut self
payload
&[u8]
&mut self
payload
&[u8]