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
use crate::*;
use std::io::{Read, Result, Write};
#[derive(Shrinkwrap, Debug)]
#[shrinkwrap(mutable)]
pub struct StdStreamAdapter<T: InStreamStd> {
#[shrinkwrap(main_field)]
pub stream: T,
}
impl<T: InStreamStd> StdStreamAdapter<T> {
pub fn new(stream: T) -> Self {
Self { stream }
}
pub fn into_inner(self) -> T {
self.stream
}
}
impl<T: InStreamStd> Read for StdStreamAdapter<T> {
fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
self.stream.read(buf)
}
}
impl<T: InStreamStd> Write for StdStreamAdapter<T> {
fn write(&mut self, buf: &[u8]) -> Result<usize> {
self.stream.write(buf)
}
fn flush(&mut self) -> Result<()> {
self.stream.flush()
}
}