rust_par2/lib.rs
1//! Pure Rust PAR2 verify and repair.
2//!
3//! The first Rust crate with full PAR2 repair support. Implements GF(2^16)
4//! arithmetic with the PAR2-mandated polynomial `0x1100B` and Reed-Solomon
5//! decoding for block-level repair.
6//!
7//! # Usage
8//!
9//! ```no_run
10//! use std::path::Path;
11//!
12//! let par2_path = Path::new("/downloads/movie/movie.par2");
13//! let job_dir = Path::new("/downloads/movie");
14//!
15//! // Parse the PAR2 index file
16//! let file_set = rust_par2::parse(par2_path).unwrap();
17//!
18//! // Verify all files
19//! let result = rust_par2::verify(&file_set, job_dir);
20//!
21//! if result.all_correct() {
22//! println!("All files intact");
23//! } else if result.repair_possible {
24//! // Repair damaged/missing files
25//! let repair = rust_par2::repair(&file_set, job_dir).unwrap();
26//! println!("{repair}");
27//! }
28//! ```
29
30pub mod gf;
31pub mod gf_simd;
32pub mod matrix;
33mod packets;
34pub mod recovery;
35pub mod repair;
36pub mod types;
37mod verify;
38
39pub use packets::{parse_par2_file as parse, parse_par2_reader, ParseError};
40pub use types::{
41 DamagedFile, Md5Hash, MissingFile, Par2File, Par2FileSet, SliceChecksum, VerifiedFile,
42 VerifyResult,
43};
44pub use repair::{repair, repair_from_verify, RepairError, RepairResult};
45pub use verify::{compute_hash_16k, verify};
46
47/// Re-export SIMD functions for benchmarks.
48pub mod gf_simd_public {
49 pub use crate::gf_simd::{mul_add_buffer, mul_add_multi, xor_buffers};
50}