Skip to content

Commit

Permalink
Merge pull request #75 from Kixunil/read_exact_write_all
Browse files Browse the repository at this point in the history
Override `read_exact` and `write_all`
  • Loading branch information
cuviper authored Jul 26, 2022
2 parents 39cec17 + 1204a49 commit fad7d3a
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1051,9 +1051,17 @@ where
for_both!(*self, ref mut inner => inner.read(buf))
}

fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> {
for_both!(*self, ref mut inner => inner.read_exact(buf))
}

fn read_to_end(&mut self, buf: &mut std::vec::Vec<u8>) -> io::Result<usize> {
for_both!(*self, ref mut inner => inner.read_to_end(buf))
}

fn read_to_string(&mut self, buf: &mut std::string::String) -> io::Result<usize> {
for_both!(*self, ref mut inner => inner.read_to_string(buf))
}
}

#[cfg(any(test, feature = "use_std"))]
Expand Down Expand Up @@ -1084,6 +1092,14 @@ where
fn consume(&mut self, amt: usize) {
for_both!(*self, ref mut inner => inner.consume(amt))
}

fn read_until(&mut self, byte: u8, buf: &mut std::vec::Vec<u8>) -> io::Result<usize> {
for_both!(*self, ref mut inner => inner.read_until(byte, buf))
}

fn read_line(&mut self, buf: &mut std::string::String) -> io::Result<usize> {
for_both!(*self, ref mut inner => inner.read_line(buf))
}
}

#[cfg(any(test, feature = "use_std"))]
Expand All @@ -1099,6 +1115,14 @@ where
for_both!(*self, ref mut inner => inner.write(buf))
}

fn write_all(&mut self, buf: &[u8]) -> io::Result<()> {
for_both!(*self, ref mut inner => inner.write_all(buf))
}

fn write_fmt(&mut self, fmt: fmt::Arguments<'_>) -> io::Result<()> {
for_both!(*self, ref mut inner => inner.write_fmt(fmt))
}

fn flush(&mut self) -> io::Result<()> {
for_both!(*self, ref mut inner => inner.flush())
}
Expand Down

0 comments on commit fad7d3a

Please sign in to comment.