1extern crate brotli_decompressor;
2#[cfg(not(feature="std"))]
3fn main() {
4 panic!("For no-stdlib examples please see the tests")
5}
6#[cfg(feature="std")]
7fn main() {
8 use std::io;
9 let stdin = &mut io::stdin();
10 {
11 use std::io::{Read, Write};
12 let mut reader = brotli_decompressor::Decompressor::new(
13 stdin,
14 4096, );
16 let mut buf = [0u8; 4096];
17 loop {
18 match reader.read(&mut buf[..]) {
19 Err(e) => {
20 if let io::ErrorKind::Interrupted = e.kind() {
21 continue;
22 }
23 panic!("{:?}", e);
24 }
25 Ok(size) => {
26 if size == 0 {
27 break;
28 }
29 match io::stdout().write_all(&buf[..size]) {
30 Err(e) => panic!("{:?}", e),
31 Ok(_) => {},
32 }
33 }
34 }
35 }
36 }
37}