// Uses the async/await mechanism for writing to the socket.
// Returns None always, as the complete payload is written.
Uses the async/await mechanism for writing to the socket.
Returns None always, as the complete payload is written.
Uses the async / await mechanism for writing to the socket . Returns None always as the complete payload is written .
async fn write_using_await(&mut self, payload: Vec<u8>) -> Option<Vec<u8>> {
        let count: Vec<u8> = payload
            .iter()
            .filter(|&v| *v == payload[0])
            .cloned()
            .collect::<Vec<u8>>();
        assert_eq!(count.len(), payload.len());
        match self.writer.write_all(&payload).await {
            Ok(_) => {
                println!(
                    "write_await(): complete({}): sent = {}",
                    payload[0],
                    payload.len(),
                );
                None
            }
            Err(e) => panic!("Failed to write: {}", e),
        }
    }
async fn write_using_await ( & mut self , payload : Vec < u8 > ) -> Option < Vec < u8 > > { let count : Vec < u8 > = payload . iter ( ) . filter ( | & v | * v == payload [ 0 ] ) . cloned ( ) . collect :: < Vec < u8 > > ( ) ; assert_eq ! ( count len ( ) payload len ( ) ) ; match self . writer . write_all ( & payload ) . await { Ok ( _ ) => { println ! ( " " payload [ 0 ] payload len ( ) ) ; None } Err ( e ) => panic ! ( " " e ) , } }
Uses the async/await mechanism for writing to the socket.
Uses the async / await mechanism for writing to the socket .
&mut self
payload
Vec<u8>