summaryrefslogtreecommitdiff
path: root/src/io.rs
blob: ec47e1d3072568dcb5396f4bc03328c49d270b8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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;
}