fn on_net_read(&mut self, n: usize) -> Result<Vec<tl::enums::Updates>, ReadError> {
        if n == 0 {
            return Err(ReadError::Io(io::Error::new(
                io::ErrorKind::ConnectionReset,
                "read 0 bytes",
            )));
        }

        trace!("read {} bytes from the network", n);

        trace!(
            "trying to unpack buffer of {} bytes...",
            self.read_buffer.len()
        );

        // TODO the buffer might have multiple transport packets, what should happen with the
        // updates successfully read if subsequent packets fail to be deserialized properly?
        let mut updates = Vec::new();
        while !self.read_buffer.is_empty() {
            self.mtp_buffer.clear();
            match self
                .transport
                .unpack(&self.read_buffer, &mut self.mtp_buffer)
            {
                Ok(n) => {
                    self.read_buffer.advance(n);
                    self.process_mtp_buffer(&mut updates)?;
                }
                Err(transport::Error::MissingBytes) => break,
                Err(err) => return Err(err.into()),
            }
        }

        Ok(updates)
    }
/// Handle `n` more read bytes being ready to process by the transport.
///
/// This won't cause `ReadError::Io`, but yet another enum would be overkill.
Handle `n` more read bytes being ready to process by the transport.
This won't cause `ReadError::Io`, but yet another enum would be overkill.
Handle ` n ` more read bytes being ready to process by the transport . This won ' t cause ` ReadError :: Io ` but yet another enum would be overkill .
fn on_net_read(&mut self, n: usize) -> Result<Vec<tl::enums::Updates>, ReadError> {
        if n == 0 {
            return Err(ReadError::Io(io::Error::new(
                io::ErrorKind::ConnectionReset,
                "read 0 bytes",
            )));
        }
        trace!("read {} bytes from the network", n);
        trace!(
            "trying to unpack buffer of {} bytes...",
            self.read_buffer.len()
        );
        // TODO the buffer might have multiple transport packets, what should happen with the
        // updates successfully read if subsequent packets fail to be deserialized properly?
        let mut updates = Vec::new();
        while !self.read_buffer.is_empty() {
            self.mtp_buffer.clear();
            match self
                .transport
                .unpack(&self.read_buffer, &mut self.mtp_buffer)
            {
                Ok(n) => {
                    self.read_buffer.advance(n);
                    self.process_mtp_buffer(&mut updates)?;
                }
                Err(transport::Error::MissingBytes) => break,
                Err(err) => return Err(err.into()),
            }
        }
        Ok(updates)
    }
fn on_net_read ( & mut self , n : usize ) -> Result < Vec < tl :: enums :: Updates > , ReadError > { if n == 0 { return Err ( ReadError :: Io ( io :: Error :: new ( io :: ErrorKind :: ConnectionReset , " " , ) ) ) ; } trace ! ( " " n ) ; trace ! ( " " self read_buffer len ( ) ) ; // TODO the buffer might have multiple transport packets, what should happen with the // updates successfully read if subsequent packets fail to be deserialized properly? let mut updates = Vec :: new ( ) ; while ! self . read_buffer . is_empty ( ) { self . mtp_buffer . clear ( ) ; match self . transport . unpack ( & self . read_buffer , & mut self . mtp_buffer ) { Ok ( n ) => { self . read_buffer . advance ( n ) ; self . process_mtp_buffer ( & mut updates ) ? ; } Err ( transport :: Error :: MissingBytes ) => break , Err ( err ) => return Err ( err . into ( ) ) , } } Ok ( updates ) }
Handle `n` more read bytes being ready to process by the transport.
Handle ` n ` more read bytes being ready to process by the transport .
&mut self
n
usize
&mut self
n
usize