From be3a50bcbc8abf271dabd40aa87379fac635cbfb Mon Sep 17 00:00:00 2001 From: Naden Date: Sat, 24 Jul 2021 22:09:54 +1000 Subject: [PATCH 1/2] Advance ReadBuf when filling --- src/reader.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/reader.rs b/src/reader.rs index a286cc1..500de2f 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -59,6 +59,7 @@ impl PipeReader { let len = data.len.min(buf.capacity()); unsafe { ptr::copy_nonoverlapping(data.ptr, buf.initialize_unfilled().as_mut_ptr(), len); + buf.advance(len); } len } From 6596127b10598b0383ed64b5a7e1ad802062143e Mon Sep 17 00:00:00 2001 From: Naden Date: Sun, 25 Jul 2021 21:51:12 +1000 Subject: [PATCH 2/2] Derive clone for reader/writer --- src/reader.rs | 1 + src/writer.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/reader.rs b/src/reader.rs index 500de2f..c64a7f5 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -6,6 +6,7 @@ use std::task::{Context, Poll}; use tokio::io::{self, AsyncRead, ReadBuf}; /// The read half of the pipe which implements [`AsyncRead`](https://docs.rs/tokio/0.2.15/tokio/io/trait.AsyncRead.html). +#[derive(Clone)] pub struct PipeReader { pub(crate) state: Arc>, } diff --git a/src/writer.rs b/src/writer.rs index 119fcca..a8b3e5d 100644 --- a/src/writer.rs +++ b/src/writer.rs @@ -6,6 +6,7 @@ use std::task::{Context, Poll}; use tokio::io::{self, AsyncWrite}; /// The write half of the pipe which implements [`AsyncWrite`](https://docs.rs/tokio/0.2.16/tokio/io/trait.AsyncWrite.html). +#[derive(Clone)] pub struct PipeWriter { pub(crate) state: Arc>, }