1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//! Content verification primitives for downloaded artifacts.
//!
//! Zero-copy streaming verification for downloaded artifacts, ensuring integrity
//! without additional memory overhead.
//!
//! # Design Principles
//!
//! - **Zero-Copy Verification**: CPU cache touches bytes only once (hashing + I/O)
//! - **Composability**: Generic over any `Hasher` trait implementation
//! - **Extensibility**: Built on `digest::Digest` for broad algorithm support
//! - **Error Handling**: Concrete error types using `thiserror`
//!
//! # Key Features
//!
//! - **Zero-copy verification**: CPU cache touches bytes only once (for both hashing and writing)
//! - **Incremental**: Computes digests as data streams through
//! - **Extensible**: Minimal `Hasher` trait allows custom implementations
//! - **Thread-safe**: All public types implement `Send + Sync`
//!
//! # Example
//!
//! ```
//! use pulith_verify::{VerifiedReader, Sha256Hasher, VerifyError};
//! use std::fs::File;
//! use std::io::{self, Read};
//!
//! fn verify_artifact(path: &str, expected_hash_hex: &str) -> Result<(), VerifyError> {
//! let expected = hex::decode(expected_hash_hex)?;
//! let file = File::open(path)?;
//! let hasher = Sha256Hasher::new();
//! let mut reader = VerifiedReader::new(file, hasher);
//!
//! let mut buffer = vec![0; 8192];
//! loop {
//! match reader.read(&mut buffer) {
//! Ok(0) => break,
//! Ok(_) => {},
//! Err(e) => return Err(VerifyError::Io(e)),
//! }
//! }
//!
//! reader.finish(&expected)?;
//! Ok(())
//! }
//! ```
pub use ;
pub use ;
pub use VerifiedReader;
pub use Sha256Hasher;
pub use Blake3Hasher;
pub use Sha3_256Hasher;