summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2020-05-05 09:21:17 +0200
committerYorhel <git@yorhel.nl>2020-05-05 09:21:19 +0200
commitcd4cca1803c8597ec4b3c811a1c1a9d61498581c (patch)
treedff4ca3a94b1492459483bf5b87a6c73b78af087
parent30b68756cbc0a32c67af3165900272e9fb0f0900 (diff)
Add support for read_vectored() and write_vectored()
Introduced in Rust 1.36.
-rw-r--r--lib.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib.rs b/lib.rs
index 7a0a0a1..1500467 100644
--- a/lib.rs
+++ b/lib.rs
@@ -196,6 +196,14 @@ impl io::Read for &Stream {
Stream::Unix(s) => (&mut (&*s)).read(buf)
}
}
+
+ fn read_vectored(&mut self, bufs: &mut [io::IoSliceMut]) -> io::Result<usize> {
+ match self {
+ Stream::Inet(s) => (&mut (&*s)).read_vectored(bufs),
+ #[cfg(unix)]
+ Stream::Unix(s) => (&mut (&*s)).read_vectored(bufs)
+ }
+ }
}
impl io::Write for &Stream {
@@ -207,6 +215,14 @@ impl io::Write for &Stream {
}
}
+ fn write_vectored(&mut self, bufs: &[io::IoSlice]) -> io::Result<usize> {
+ match self {
+ Stream::Inet(s) => (&mut (&*s)).write_vectored(bufs),
+ #[cfg(unix)]
+ Stream::Unix(s) => (&mut (&*s)).write_vectored(bufs)
+ }
+ }
+
fn flush(&mut self) -> io::Result<()> {
match self {
Stream::Inet(s) => (&mut (&*s)).flush(),
@@ -218,10 +234,12 @@ impl io::Write for &Stream {
impl io::Read for Stream {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { (&mut &*self).read(buf) }
+ fn read_vectored(&mut self, bufs: &mut [io::IoSliceMut]) -> io::Result<usize> { (&mut &*self).read_vectored(bufs) }
}
impl io::Write for Stream {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> { (&mut &*self).write(buf) }
+ fn write_vectored(&mut self, bufs: &[io::IoSlice]) -> io::Result<usize> { (&mut &*self).write_vectored(bufs) }
fn flush(&mut self) -> io::Result<()> { (&mut &*self).flush() }
}