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
use std::io;
use std::io::Write;
use super::*;
use crate::api;
#[derive(Debug)]
pub struct ChildStdin {
pub(super) context: api::ProcessClient,
}
impl ChildStdin {
pub fn new(context: api::ProcessClient) -> ChildStdin {
ChildStdin { context }
}
}
impl Write for ChildStdin {
fn write(&mut self, buf: &[u8]) -> Result<usize> {
Ok(self
.context
.blocking_stdin(buf.to_vec())
.map_err(|err| err.into_io_error())?)
}
fn flush(&mut self) -> io::Result<()> {
Ok(self
.context
.blocking_flush()
.map_err(|err| err.into_io_error())?)
}
}