Debian Codegraph @

examples/train.rs

raw symbols SCIP
1 use clap::Parser;
2 use std::io;
3 use std::path::PathBuf;
4
5 #[derive(Parser, Debug)]
6 #[command(author, version, about, long_about=None)]
7 /// This program trains a dictionary from one or more files,
8 /// to make future compression of similar small files more efficient.
9 ///
10 /// The dictionary will need to be present during decompression,
11 /// but if you need to compress many small files individually,
12 /// it may be worth the trouble.
13 struct Args {
14 /// Maximum dictionary size in bytes.
15 #[arg(short, long)]
16 max_size: usize,
17
18 /// Files to use as input.
19 files: Vec<PathBuf>,
20 }
21
22 fn main() {
23 let args = Args::parse();
24
25 let dict = zstd::dict::from_files(&args.files, args.max_size).unwrap();
26
27 let mut dict_reader: &[u8] = &dict;
28 io::copy(&mut dict_reader, &mut io::stdout()).unwrap();
29 }