Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override read_exact and write_all #75

Merged
merged 4 commits into from
Jul 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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