1 // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
12 use sys::cloudabi::abi;
15 pub struct Stdout(());
16 pub struct Stderr(());
19 pub fn new() -> io::Result<Stdin> {
23 pub fn read(&self, _: &mut [u8]) -> io::Result<usize> {
29 pub fn new() -> io::Result<Stdout> {
33 pub fn write(&self, _: &[u8]) -> io::Result<usize> {
35 io::ErrorKind::BrokenPipe,
36 "Stdout is not connected to any output in this environment",
40 pub fn flush(&self) -> io::Result<()> {
46 pub fn new() -> io::Result<Stderr> {
50 pub fn write(&self, _: &[u8]) -> io::Result<usize> {
52 io::ErrorKind::BrokenPipe,
53 "Stderr is not connected to any output in this environment",
57 pub fn flush(&self) -> io::Result<()> {
62 // FIXME: right now this raw stderr handle is used in a few places because
63 // std::io::stderr_raw isn't exposed, but once that's exposed this impl
65 impl io::Write for Stderr {
66 fn write(&mut self, data: &[u8]) -> io::Result<usize> {
67 Stderr::write(self, data)
70 fn flush(&mut self) -> io::Result<()> {
75 pub fn is_ebadf(err: &io::Error) -> bool {
76 err.raw_os_error() == Some(abi::errno::BADF as i32)
79 pub const STDIN_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE;
81 pub fn stderr_prints_nothing() -> bool {