1 // Copyright 2017 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::{Void, unsupported};
14 pub struct Stdin(Void);
19 pub fn new() -> io::Result<Stdin> {
23 pub fn read(&self, _data: &mut [u8]) -> io::Result<usize> {
29 pub fn new() -> io::Result<Stdout> {
33 pub fn write(&self, data: &[u8]) -> io::Result<usize> {
34 // If runtime debugging is enabled at compile time we'll invoke some
35 // runtime functions that are defined in our src/etc/wasm32-shim.js
36 // debugging script. Note that this ffi function call is intended
37 // *purely* for debugging only and should not be relied upon.
42 fn rust_wasm_write_stdout(data: *const u8, len: usize);
45 rust_wasm_write_stdout(data.as_ptr(), data.len())
50 pub fn flush(&self) -> io::Result<()> {
56 pub fn new() -> io::Result<Stderr> {
60 pub fn write(&self, data: &[u8]) -> io::Result<usize> {
61 // See comments in stdout for what's going on here.
66 fn rust_wasm_write_stderr(data: *const u8, len: usize);
69 rust_wasm_write_stderr(data.as_ptr(), data.len())
74 pub fn flush(&self) -> io::Result<()> {
79 impl io::Write for Stderr {
80 fn write(&mut self, data: &[u8]) -> io::Result<usize> {
83 fn flush(&mut self) -> io::Result<()> {
88 pub const STDIN_BUF_SIZE: usize = 0;
90 pub fn is_ebadf(_err: &io::Error) -> bool {