async fn read_using_poll(&mut self, payload: &mut [u8]) -> usize {
        let fut = self.reader.read(payload);
        match poll!(fut) {
            Poll::Ready(result) => match result {
                Ok(read) => {
                    if read < payload.len() {
                        println!(
                            "read_poll(): Poll::Ready/partial({}): read = {}, remaining = {}",
                            payload[0],
                            read,
                            payload.len() - read
                        );
                    } else {
                        println!(
                            "read_poll(): Poll::Ready/complete({}): read = {}",
                            payload[0], read,
                        );
                    }
                    read
                }
                Err(e) => {
                    panic!("read_poll(): Read failed: {:?}", e);
                }
            },
            Poll::Pending => {
                println!("read_poll(): complete({}): {}", payload[0], payload.len());
                0
            }
        }
    }
// Uses explicit polling of the read future.
// Returns the number of bytes read, which may be <= bytes requested. If all the
// requested bytes could not be read, the caller needs to call this again to read
// the remaining payload.
Uses explicit polling of the read future.
Returns the number of bytes read, which may be <= bytes requested. If all the
requested bytes could not be read, the caller needs to call this again to read
the remaining payload.
Uses explicit polling of the read future . Returns the number of bytes read which may be < = bytes requested . If all the requested bytes could not be read the caller needs to call this again to read the remaining payload .
async fn read_using_poll(&mut self, payload: &mut [u8]) -> usize {
        let fut = self.reader.read(payload);
        match poll!(fut) {
            Poll::Ready(result) => match result {
                Ok(read) => {
                    if read < payload.len() {
                        println!(
                            "read_poll(): Poll::Ready/partial({}): read = {}, remaining = {}",
                            payload[0],
                            read,
                            payload.len() - read
                        );
                    } else {
                        println!(
                            "read_poll(): Poll::Ready/complete({}): read = {}",
                            payload[0], read,
                        );
                    }
                    read
                }
                Err(e) => {
                    panic!("read_poll(): Read failed: {:?}", e);
                }
            },
            Poll::Pending => {
                println!("read_poll(): complete({}): {}", payload[0], payload.len());
                0
            }
        }
    }
async fn read_using_poll ( & mut self , payload : & mut [ u8 ] ) -> usize { let fut = self . reader . read ( payload ) ; match poll ! ( fut ) { Poll :: Ready ( result ) => match result { Ok ( read ) => { if read < payload . len ( ) { println ! ( " " payload [ 0 ] read payload len ( ) read ) ; } else { println ! ( " " payload [ 0 ] read ) ; } read } Err ( e ) => { panic ! ( " " e ) ; } } , Poll :: Pending => { println ! ( " " payload [ 0 ] payload len ( ) ) ; 0 } } }
Uses explicit polling of the read future.
Uses explicit polling of the read future .
&mut self
payload
&mut [u8]
&mut self
payload
&mut [u8]