Pipe example

This commit is contained in:
Heyang Zhou
2019-05-07 10:48:50 -07:00
parent 0bbd6e6970
commit accb80bca2
4 changed files with 25 additions and 1 deletions

4
Cargo.lock generated
View File

@ -1319,6 +1319,10 @@ dependencies = [
"unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "pipe"
version = "0.1.0"
[[package]]
name = "pkg-config"
version = "0.3.14"

View File

@ -36,7 +36,7 @@ wasmer-wasi = { path = "lib/wasi", optional = true }
kwasm-loader = { path = "lib/kwasm-loader" }
[workspace]
members = ["lib/clif-backend", "lib/singlepass-backend", "lib/runtime", "lib/runtime-abi", "lib/runtime-core", "lib/emscripten", "lib/spectests", "lib/win-exception-handler", "lib/runtime-c-api", "lib/llvm-backend", "lib/wasi", "lib/middleware-common", "lib/kwasm-loader", "examples/kernel/hello_world", "examples/plugin-for-example"]
members = ["lib/clif-backend", "lib/singlepass-backend", "lib/runtime", "lib/runtime-abi", "lib/runtime-core", "lib/emscripten", "lib/spectests", "lib/win-exception-handler", "lib/runtime-c-api", "lib/llvm-backend", "lib/wasi", "lib/middleware-common", "lib/kwasm-loader", "examples/kernel/hello_world", "examples/pipe", "examples/plugin-for-example"]
[build-dependencies]
wabt = "0.7.2"

7
examples/pipe/Cargo.toml Normal file
View File

@ -0,0 +1,7 @@
[package]
name = "pipe"
version = "0.1.0"
authors = ["Heyang Zhou <zhy20000919@hotmail.com>"]
edition = "2018"
[dependencies]

13
examples/pipe/src/main.rs Normal file
View File

@ -0,0 +1,13 @@
use std::io::{Read, Write};
fn main() {
let mut stdin = ::std::io::stdin();
let mut stdout = ::std::io::stdout();
let mut buf: Vec<u8> = vec![0; 512];
let mut total: u64 = 0;
while total < 1048576u64 * 2048 {
let n = stdin.read(&mut buf).unwrap();
stdout.write_all(&buf[..n]).unwrap();
total += n as u64;
}
}