pub struct HashComputer { /* private fields */ }Expand description
Hash computer with streaming I/O
Implementations§
Source§impl HashComputer
impl HashComputer
Sourcepub fn compute_hash(
&self,
path: &Path,
algorithm: &str,
) -> Result<HashResult, HashUtilityError>
pub fn compute_hash( &self, path: &Path, algorithm: &str, ) -> Result<HashResult, HashUtilityError>
Compute hash for a single file using streaming I/O or memory mapping
Uses buffered I/O for small files and memory mapping for larger files on 64-bit targets. 32-bit targets cap mappings at 2 GiB.
§Safety
Memory mapping assumes the file will not be modified by other processes during hashing. If the file is modified concurrently, the hash result may be inconsistent. This is acceptable for typical use cases where files are not being actively modified.
Sourcepub fn compute_hash_with_progress(
&self,
path: &Path,
algorithm: &str,
show_progress: bool,
) -> Result<HashResult, HashUtilityError>
pub fn compute_hash_with_progress( &self, path: &Path, algorithm: &str, show_progress: bool, ) -> Result<HashResult, HashUtilityError>
Compute hash for a single file with optional progress bar
If show_progress is true and the file is larger than 1GB and stdout is a TTY, displays a progress bar that updates 10 times per second.
Sourcepub fn compute_hash_fast(
&self,
path: &Path,
algorithm: &str,
) -> Result<HashResult, HashUtilityError>
pub fn compute_hash_fast( &self, path: &Path, algorithm: &str, ) -> Result<HashResult, HashUtilityError>
Compute hash for a file using fast mode (sampling strategy)
For files larger than 300MB, samples three 100MB regions:
- First 100MB
- Middle 100MB (centered at file_size/2)
- Last 100MB
For files smaller than 300MB, uses the full file.
Source§impl HashComputer
impl HashComputer
Sourcepub fn with_buffer_size(buffer_size: usize) -> Self
pub fn with_buffer_size(buffer_size: usize) -> Self
Create a new HashComputer with custom buffer size
Sourcepub fn buffer_size(&self) -> usize
pub fn buffer_size(&self) -> usize
Return the buffer size
Sourcepub fn compute_hash_text(
&self,
text: &str,
algorithm: &str,
) -> Result<HashResult, HashUtilityError>
pub fn compute_hash_text( &self, text: &str, algorithm: &str, ) -> Result<HashResult, HashUtilityError>
Compute hash from text string
Sourcepub fn compute_multiple_hashes_text(
&self,
text: &str,
algorithms: &[String],
) -> Result<Vec<HashResult>, HashUtilityError>
pub fn compute_multiple_hashes_text( &self, text: &str, algorithms: &[String], ) -> Result<Vec<HashResult>, HashUtilityError>
Compute multiple hashes from text string in a single pass
Sourcepub fn compute_hash_stdin(
&self,
algorithm: &str,
) -> Result<HashResult, HashUtilityError>
pub fn compute_hash_stdin( &self, algorithm: &str, ) -> Result<HashResult, HashUtilityError>
Compute hash from stdin using streaming I/O
Sourcepub fn compute_multiple_hashes_stdin(
&self,
algorithms: &[String],
) -> Result<Vec<HashResult>, HashUtilityError>
pub fn compute_multiple_hashes_stdin( &self, algorithms: &[String], ) -> Result<Vec<HashResult>, HashUtilityError>
Compute multiple hashes from stdin in a single pass
Sourcepub fn compute_multiple_hashes(
&self,
path: &Path,
algorithms: &[String],
) -> Result<Vec<HashResult>, HashUtilityError>
pub fn compute_multiple_hashes( &self, path: &Path, algorithms: &[String], ) -> Result<Vec<HashResult>, HashUtilityError>
Compute multiple hashes for a single file in a single pass
Uses buffered I/O for small files and memory mapping for larger files on 64-bit targets. 32-bit targets cap mappings at 2 GiB.
§Safety
Memory mapping assumes the file will not be modified by other processes during hashing. If the file is modified concurrently, the hash results may be inconsistent.
Sourcepub fn compute_multiple_hashes_with_progress(
&self,
path: &Path,
algorithms: &[String],
show_progress: bool,
) -> Result<Vec<HashResult>, HashUtilityError>
pub fn compute_multiple_hashes_with_progress( &self, path: &Path, algorithms: &[String], show_progress: bool, ) -> Result<Vec<HashResult>, HashUtilityError>
Compute multiple hashes for a single file with optional progress bar
If show_progress is true and the file is larger than 1GB and stdout is a TTY, displays a progress bar that updates 10 times per second.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for HashComputer
impl RefUnwindSafe for HashComputer
impl Send for HashComputer
impl Sync for HashComputer
impl Unpin for HashComputer
impl UnsafeUnpin for HashComputer
impl UnwindSafe for HashComputer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more