Debian Codegraph @

examples/decompress.rs

raw symbols SCIP
1 use bgzip::read::BGZFReader;
2 use clap::Parser;
3 use std::fs::File;
4 use std::io::prelude::*;
5
6 #[cfg(not(feature = "rayon"))]
7 #[derive(Debug, Parser)]
8 struct Cli {
9 #[command()]
10 input_file: String,
11 #[arg(short, long)]
12 output: String,
13 }
14
15 #[cfg(feature = "rayon")]
16 #[derive(Debug, Parser)]
17 struct Cli {
18 #[command()]
19 input_file: String,
20 #[arg(short, long)]
21 output: String,
22 #[arg(short = '@', long)]
23 thread: Option<usize>,
24 }
25
26 fn main() -> anyhow::Result<()> {
27 let cli = Cli::parse();
28 let file_reader = File::open(&cli.input_file)?;
29 let mut file_writer = File::create(&cli.output)?;
30
31 #[cfg(feature = "rayon")]
32 let mut reader: Box<dyn Read> = if let Some(thread) = cli.thread {
33 rayon::ThreadPoolBuilder::new()
34 .num_threads(thread)
35 .build_global()?;
36 Box::new(bgzip::read::BGZFMultiThreadReader::new(file_reader)?)
37 } else {
38 Box::new(BGZFReader::new(file_reader)?)
39 };
40
41 #[cfg(not(feature = "rayon"))]
42 let mut reader = BGZFReader::new(file_reader)?;
43
44 std::io::copy(&mut reader, &mut file_writer)?;
45
46 Ok(())
47 }