pub struct DatabaseHandler;Expand description
Handler for reading and writing hash database files
Implementations§
Source§impl DatabaseHandler
impl DatabaseHandler
Sourcepub fn checksum_algorithm_from_path(path: &Path) -> Option<Algorithm>
pub fn checksum_algorithm_from_path(path: &Path) -> Option<Algorithm>
Infer a checksum algorithm from a path’s file extension.
Sourcepub fn verification_checksum_algorithm(
path: &Path,
) -> Result<Option<Algorithm>, HashUtilityError>
pub fn verification_checksum_algorithm( path: &Path, ) -> Result<Option<Algorithm>, HashUtilityError>
Check if a path corresponds to a supported checksum format for verification.
Sourcepub fn read_checksum_manifest(path: &Path) -> Result<Manifest, HashUtilityError>
pub fn read_checksum_manifest(path: &Path) -> Result<Manifest, HashUtilityError>
Read a conventional two-column checksum file for verification.
Sourcepub fn canonical_output_path(
requested_path: &Path,
format: DatabaseFormat,
compressed: bool,
) -> Result<PathBuf, HashUtilityError>
pub fn canonical_output_path( requested_path: &Path, format: DatabaseFormat, compressed: bool, ) -> Result<PathBuf, HashUtilityError>
Return the canonical output path for a database.
Sourcepub fn write_manifest_file(
requested_path: &Path,
manifest: &Manifest,
format: DatabaseFormat,
compressed: bool,
) -> Result<PathBuf, HashUtilityError>
pub fn write_manifest_file( requested_path: &Path, manifest: &Manifest, format: DatabaseFormat, compressed: bool, ) -> Result<PathBuf, HashUtilityError>
Write a manifest to its canonical database path.
Sourcepub fn is_compressed(path: &Path) -> bool
pub fn is_compressed(path: &Path) -> bool
Check if a path has .zst or .zstd extension (compressed database)
Sourcepub fn compress_database(input_path: &Path) -> Result<PathBuf, HashUtilityError>
pub fn compress_database(input_path: &Path) -> Result<PathBuf, HashUtilityError>
Compress a database file with Zstandard.
Sourcepub fn detect_format(path: &Path) -> Result<DatabaseFormat, HashUtilityError>
pub fn detect_format(path: &Path) -> Result<DatabaseFormat, HashUtilityError>
Detect the format of a database file by reading its first few lines
Sourcepub fn write_entry(
writer: &mut impl Write,
hash: &str,
algorithm: &str,
fast_mode: bool,
path: &Path,
) -> Result<()>
pub fn write_entry( writer: &mut impl Write, hash: &str, algorithm: &str, fast_mode: bool, path: &Path, ) -> Result<()>
Write a single hash entry to the output writer
Sourcepub fn write_hashdeep_header(
writer: &mut impl Write,
algorithms: &[String],
) -> Result<()>
pub fn write_hashdeep_header( writer: &mut impl Write, algorithms: &[String], ) -> Result<()>
Write hashdeep format header
Sourcepub fn write_hashdeep_entry(
writer: &mut impl Write,
size: u64,
hashes: &[String],
path: &Path,
) -> Result<()>
pub fn write_hashdeep_entry( writer: &mut impl Write, size: u64, hashes: &[String], path: &Path, ) -> Result<()>
Write a single entry in hashdeep format
Sourcepub fn read_database(
path: &Path,
) -> Result<HashMap<PathBuf, DatabaseEntry>, HashUtilityError>
pub fn read_database( path: &Path, ) -> Result<HashMap<PathBuf, DatabaseEntry>, HashUtilityError>
Read a hash database file and parse it into a HashMap
Sourcepub fn read_manifest(path: &Path) -> Result<Manifest, HashUtilityError>
pub fn read_manifest(path: &Path) -> Result<Manifest, HashUtilityError>
Read every digest from a QuicHash or hashdeep manifest.
Sourcepub fn read_manifest_with_policy(
path: &Path,
failure_policy: FailurePolicy,
) -> Result<ManifestRead, HashUtilityError>
pub fn read_manifest_with_policy( path: &Path, failure_policy: FailurePolicy, ) -> Result<ManifestRead, HashUtilityError>
Read a typed manifest, optionally retaining malformed-line issues.
Sourcepub fn write_manifest(
writer: &mut impl Write,
manifest: &Manifest,
format: DatabaseFormat,
) -> Result<()>
pub fn write_manifest( writer: &mut impl Write, manifest: &Manifest, format: DatabaseFormat, ) -> Result<()>
Write every manifest digest in QuicHash or hashdeep format.
Sourcepub fn parse_line(line: &str) -> Option<(String, String, bool, PathBuf)>
pub fn parse_line(line: &str) -> Option<(String, String, bool, PathBuf)>
Parse a single line from a QuicHash database file.
Sourcepub fn parse_hashdeep_line(
line: &str,
algorithms: &[String],
) -> Option<Vec<(PathBuf, DatabaseEntry)>>
pub fn parse_hashdeep_line( line: &str, algorithms: &[String], ) -> Option<Vec<(PathBuf, DatabaseEntry)>>
Parse a single line from a hashdeep database file.
Auto Trait Implementations§
impl Freeze for DatabaseHandler
impl RefUnwindSafe for DatabaseHandler
impl Send for DatabaseHandler
impl Sync for DatabaseHandler
impl Unpin for DatabaseHandler
impl UnsafeUnpin for DatabaseHandler
impl UnwindSafe for DatabaseHandler
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