[][src]Function autocompress::open_or_stdin

pub fn open_or_stdin(
    path: Option<impl AsRef<Path>>
) -> Result<Decoder<BufReader<Box<dyn Read>>>>

Open new reader from file path. If path is None, standard input is used. File format is suggested from magic bytes and file extension.

let mut buffer = Vec::new();
open_or_stdin(Some("testfiles/plain.txt.xz"))?.read_to_end(&mut buffer)?;
assert_eq!(buffer, b"ABCDEFG\r\n1234567");