pub async fn send_bytes(payload: Vec<u8>, socket: &mut TcpStream) -> Result<()> {
    let message_size = payload.len() as u64;

    let mut header = vec![];
    header.write_u64::<BigEndian>(message_size).unwrap();

    // Send the request size header first.
    // Afterwards send the request.
    socket.write_all(&header).await?;

    // Split the payload into 1.5kbyte chunks (MUT for TCP)
    let mut iter = payload.chunks(1500);
    while let Some(chunk) = iter.next() {
        socket.write_all(chunk).await?;
    }

    Ok(())
}
/// Send a Vec of bytes. Before the actual bytes are send, the size of the message
/// is transmitted in an header of fixed size (u64).
Send a Vec of bytes. Before the actual bytes are send, the size of the message
is transmitted in an header of fixed size (u64).
Send a Vec of bytes . Before the actual bytes are send the size of the message is transmitted in an header of fixed size ( u64 ) .
pub async fn send_bytes(payload: Vec<u8>, socket: &mut TcpStream) -> Result<()> {
    let message_size = payload.len() as u64;
    let mut header = vec![];
    header.write_u64::<BigEndian>(message_size).unwrap();
    // Send the request size header first.
    // Afterwards send the request.
    socket.write_all(&header).await?;
    // Split the payload into 1.5kbyte chunks (MUT for TCP)
    let mut iter = payload.chunks(1500);
    while let Some(chunk) = iter.next() {
        socket.write_all(chunk).await?;
    }
    Ok(())
}
pub async fn send_bytes ( payload : Vec < u8 > , socket : & mut TcpStream ) -> Result < ( ) > { let message_size = payload . len ( ) as u64 ; let mut header = vec ! [ ] ; header . write_u64 :: < BigEndian > ( message_size ) . unwrap ( ) ; // Send the request size header first. // Afterwards send the request. socket . write_all ( & header ) . await ? ; // Split the payload into 1.5kbyte chunks (MUT for TCP) let mut iter = payload . chunks ( 1500 ) ; while let Some ( chunk ) = iter . next ( ) { socket . write_all ( chunk ) . await ? ; } Ok ( ( ) ) }
Send a Vec of bytes.
Send a Vec of bytes .
payload
Vec<u8>
socket
&mut TcpStream
payload
Vec<u8>
socket
&mut TcpStream