# rust-par2
Pure Rust PAR2 verify and repair with SIMD-accelerated Galois field arithmetic.
## This Is a Shared Library
### Consumed By
| nzb-postproc (lib) | crates.io (v0.1) |
| rustnzbd | crates.io (v0.1.1) |
| Arz | crates.io (v0.1) |
| rustnzbindxer | vendored (path) |
### No Upstream Dependencies
This crate has no dependencies on other workspace libs.
## Public API
```rust
// Parsing
pub fn parse(path: &Path) -> Result<Par2FileSet, ParseError>;
pub fn parse_par2_reader(reader, size) -> Result<Par2FileSet>;
// Verification
pub fn verify(file_set: &Par2FileSet, dir: &Path) -> VerifyResult;
pub fn compute_hash_16k(path: &Path) -> Result<Md5Hash>;
// Repair
pub fn repair(file_set: &Par2FileSet, dir: &Path) -> Result<RepairResult, RepairError>;
pub fn repair_from_verify(file_set, dir, verify_result) -> Result<RepairResult>;
pub fn repair_from_verify_no_reverify(file_set, dir, verify_result) -> Result<RepairResult>;
```
### Key Types
- **`Par2FileSet`** — parsed recovery set (files, slice checksums, recovery block count)
- **`Par2File`** — file metadata (hash, hash_16k, size, filename, slices)
- **`VerifyResult`** — intact/damaged/missing files, recovery_blocks_available, repair_possible
- **`RepairResult`** — success, blocks_repaired, files_repaired
- **`RepairError`** — Io, InsufficientRecovery, SingularMatrix, NoDamage, VerifyFailed, ParseError
## Architecture
- **GF(2^16)** with polynomial 0x1100B, log/antilog tables
- **SIMD paths**: AVX2 (preferred) -> SSSE3 -> scalar fallback
- **Vandermonde matrix** for Reed-Solomon decoding
- **Double-buffered reader thread** for streaming I/O during repair
- **Parallel** via rayon for multi-file verification
## Key Dependencies
- md-5 (MD5 hashing, with asm acceleration)
- crc32fast (CRC32 checksums)
- rayon (data parallelism)