pub(crate) fn write_stored_packet<T>(conn: &mut OssuaryConnection,
                                     stream: &mut T) -> Result<usize, OssuaryError>
where T: std::io::Write {
    let mut written = 0;
    while written < conn.write_buf_used {
        match stream.write(&conn.write_buf[written..conn.write_buf_used]) {
            Ok(w) => {
                written += w;
            },
            Err(e) => {
                if written > 0 && written < conn.write_buf_used {
                    unsafe {
                        // no safe way to memmove() in Rust?
                        std::ptr::copy::<u8>(
                            conn.write_buf.as_ptr().offset(written as isize),
                            conn.write_buf.as_mut_ptr(),
                            conn.write_buf_used - written);
                    }
                }
                conn.write_buf_used -= written;
                return Err(e.into());
            },
        }
    }
    conn.write_buf_used = 0;
    Ok(written)
}
/// Write a packet from OssuaryConnection's internal storage to the out buffer.
///
/// All packets are buffered to internal storage before writing, so this is
/// the function responsible for putting all packets "on the wire".
///
/// On success, returns the number of bytes written to the output buffer
Write a packet from OssuaryConnection's internal storage to the out buffer.
All packets are buffered to internal storage before writing, so this is
the function responsible for putting all packets "on the wire".

On success, returns the number of bytes written to the output buffer
Write a packet from OssuaryConnection ' s internal storage to the out buffer . All packets are buffered to internal storage before writing so this is the function responsible for putting all packets " on the wire " . On success returns the number of bytes written to the output buffer
pub(crate) fn write_stored_packet<T>(conn: &mut OssuaryConnection,
                                     stream: &mut T) -> Result<usize, OssuaryError>
where T: std::io::Write {
    let mut written = 0;
    while written < conn.write_buf_used {
        match stream.write(&conn.write_buf[written..conn.write_buf_used]) {
            Ok(w) => {
                written += w;
            },
            Err(e) => {
                if written > 0 && written < conn.write_buf_used {
                    unsafe {
                        // no safe way to memmove() in Rust?
                        std::ptr::copy::<u8>(
                            conn.write_buf.as_ptr().offset(written as isize),
                            conn.write_buf.as_mut_ptr(),
                            conn.write_buf_used - written);
                    }
                }
                conn.write_buf_used -= written;
                return Err(e.into());
            },
        }
    }
    conn.write_buf_used = 0;
    Ok(written)
}
pub ( crate ) fn write_stored_packet < T > ( conn : & mut OssuaryConnection , stream : & mut T ) -> Result < usize , OssuaryError > where T : std :: io :: Write { let mut written = 0 ; while written < conn . write_buf_used { match stream . write ( & conn . write_buf [ written .. conn . write_buf_used ] ) { Ok ( w ) => { written += w ; } , Err ( e ) => { if written > 0 && written < conn . write_buf_used { unsafe { // no safe way to memmove() in Rust? std :: ptr :: copy :: < u8 > ( conn . write_buf . as_ptr ( ) . offset ( written as isize ) , conn . write_buf . as_mut_ptr ( ) , conn . write_buf_used - written ) ; } } conn . write_buf_used -= written ; return Err ( e . into ( ) ) ; } , } } conn . write_buf_used = 0 ; Ok ( written ) }
Write a packet from OssuaryConnection's internal storage to the out buffer.
Write a packet from OssuaryConnection ' s internal storage to the out buffer .
conn
&mut OssuaryConnection
stream
&mut T
conn
&mut OssuaryConnection
stream
&mut T