|
|
|
@ -87,6 +87,9 @@ where T: AsyncWrite
|
|
|
|
|
|
|
|
|
|
for chunk in this.buffer.chunks_exact(SIZE)
|
|
|
|
|
{
|
|
|
|
|
if cfg!(test) {
|
|
|
|
|
eprintln!("Pushing chunk: {:?}", chunk);
|
|
|
|
|
}
|
|
|
|
|
match this.stream.write_all(&chunk).await {
|
|
|
|
|
Ok(()) => {
|
|
|
|
|
written += chunk.len();
|
|
|
|
@ -114,7 +117,12 @@ where T: AsyncWrite
|
|
|
|
|
use tokio::prelude::*;
|
|
|
|
|
|
|
|
|
|
let wres = if this.buffer.len() > 0 {
|
|
|
|
|
this.stream.write_all(&this.buffer[..]).await
|
|
|
|
|
if cfg!(test) {
|
|
|
|
|
eprintln!("Pushing rest: {:?}", &this.buffer[..]);
|
|
|
|
|
}
|
|
|
|
|
let res = this.stream.write_all(&this.buffer[..]).await;
|
|
|
|
|
this.buffer.clear();
|
|
|
|
|
res
|
|
|
|
|
} else {
|
|
|
|
|
Ok(())
|
|
|
|
|
};
|
|
|
|
@ -157,7 +165,7 @@ mod tests
|
|
|
|
|
use tokio::prelude::*;
|
|
|
|
|
|
|
|
|
|
let (tx, mut rx) = tokio::io::duplex(11);
|
|
|
|
|
let mut ttx = Buffered::<_, 16>::new(tx);
|
|
|
|
|
let mut ttx = Buffered::<_, 4>::new(tx);
|
|
|
|
|
|
|
|
|
|
let back = tokio::spawn(async move {
|
|
|
|
|
|
|
|
|
@ -167,6 +175,7 @@ mod tests
|
|
|
|
|
tokio::time::delay_for(tokio::time::Duration::from_secs(1)).await;
|
|
|
|
|
println!("Flushing stream");
|
|
|
|
|
ttx.flush().await?;
|
|
|
|
|
ttx.shutdown().await?;
|
|
|
|
|
Result::<_, std::io::Error>::Ok(())
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|