Merge pull request #1530 from cumthugo/write_func_in_pipe

sync/pipe: write all user data to pipe
This commit is contained in:
Dario Nieuwenhuis 2023-06-05 02:48:36 +02:00 committed by GitHub
commit d690a1717f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -294,6 +294,16 @@ where
WriteFuture { pipe: self, buf }
}
/// Write all bytes to the pipe.
///
/// This method writes all bytes from `buf` into the pipe
pub async fn write_all(&self, mut buf: &[u8]) {
while !buf.is_empty() {
let n = self.write(buf).await;
buf = &buf[n..];
}
}
/// Attempt to immediately write some bytes to the pipe.
///
/// This method will either write a nonzero amount of bytes to the pipe immediately,