1extern crate brotli;
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::new(
13 stdin, 4096, );
15 let mut buf = [0u8; 4096];
16 loop {
17 match reader.read(&mut buf[..]) {
18 Err(e) => {
19 if let io::ErrorKind::Interrupted = e.kind() {
20 continue;
21 }
22 panic!("{}", e);
23 }
24 Ok(size) => {
25 if size == 0 {
26 break;
27 }
28 match io::stdout().write_all(&buf[..size]) {
29 Err(e) => panic!("{}", e),
30 Ok(_) => {}
31 }
32 }
33 }
34 }
35 }
36}