summaryrefslogtreecommitdiff
path: root/src/io.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/io.rs')
-rw-r--r--src/io.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/io.rs b/src/io.rs
new file mode 100644
index 0000000..ec47e1d
--- /dev/null
+++ b/src/io.rs
@@ -0,0 +1,37 @@
+use std::io::{Read, Write, Result};
+
+pub struct RWBundle<R: Read, W: Write>(pub R, pub W);
+impl<R: Read, W: Write> Read for RWBundle<R, W>{
+ fn read(&mut self, buf: &mut [u8]) -> Result<usize>{
+ self.0.read(buf)
+ }
+ //fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize>;
+ //fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize>;
+ //fn read_to_string(&mut self, buf: &mut String) -> Result<usize>;
+ fn read_exact(&mut self, buf: &mut [u8]) -> Result<()>{
+ self.0.read_exact(buf)
+ }
+ //fn by_ref(&mut self) -> &mut Self
+ // where Self: Sized;
+ //fn bytes(self) -> Bytes<Self>
+ // where Self: Sized;
+ //fn chain<R: Read>(self, next: R) -> Chain<Self, R>
+ // where Self: Sized;
+ //fn take(self, limit: u64) -> Take<Self>
+ // where Self: Sized;
+}
+impl<R: Read, W: Write> Write for RWBundle<R, W>{
+ fn write(&mut self, buf: &[u8]) -> Result<usize>{
+ self.1.write(buf)
+ }
+ fn flush(&mut self) -> Result<()>{
+ self.1.flush()
+ }
+ //fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize>;
+ fn write_all(&mut self, buf: &[u8]) -> Result<()>{
+ self.1.write_all(buf)
+ }
+ //fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<()>;
+ //fn by_ref(&mut self) -> &mut Self
+ // where Self: Sized;
+}