Skip to content

Commit fad7d3a

Browse files
authored
Merge pull request #75 from Kixunil/read_exact_write_all
Override `read_exact` and `write_all`
2 parents 39cec17 + 1204a49 commit fad7d3a

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/lib.rs

+24
Original file line numberDiff line numberDiff line change
@@ -1051,9 +1051,17 @@ where
10511051
for_both!(*self, ref mut inner => inner.read(buf))
10521052
}
10531053

1054+
fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> {
1055+
for_both!(*self, ref mut inner => inner.read_exact(buf))
1056+
}
1057+
10541058
fn read_to_end(&mut self, buf: &mut std::vec::Vec<u8>) -> io::Result<usize> {
10551059
for_both!(*self, ref mut inner => inner.read_to_end(buf))
10561060
}
1061+
1062+
fn read_to_string(&mut self, buf: &mut std::string::String) -> io::Result<usize> {
1063+
for_both!(*self, ref mut inner => inner.read_to_string(buf))
1064+
}
10571065
}
10581066

10591067
#[cfg(any(test, feature = "use_std"))]
@@ -1084,6 +1092,14 @@ where
10841092
fn consume(&mut self, amt: usize) {
10851093
for_both!(*self, ref mut inner => inner.consume(amt))
10861094
}
1095+
1096+
fn read_until(&mut self, byte: u8, buf: &mut std::vec::Vec<u8>) -> io::Result<usize> {
1097+
for_both!(*self, ref mut inner => inner.read_until(byte, buf))
1098+
}
1099+
1100+
fn read_line(&mut self, buf: &mut std::string::String) -> io::Result<usize> {
1101+
for_both!(*self, ref mut inner => inner.read_line(buf))
1102+
}
10871103
}
10881104

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

1118+
fn write_all(&mut self, buf: &[u8]) -> io::Result<()> {
1119+
for_both!(*self, ref mut inner => inner.write_all(buf))
1120+
}
1121+
1122+
fn write_fmt(&mut self, fmt: fmt::Arguments<'_>) -> io::Result<()> {
1123+
for_both!(*self, ref mut inner => inner.write_fmt(fmt))
1124+
}
1125+
11021126
fn flush(&mut self) -> io::Result<()> {
11031127
for_both!(*self, ref mut inner => inner.flush())
11041128
}

0 commit comments

Comments
 (0)