Skip to main content

DatabaseHandler

Struct DatabaseHandler 

Source
pub struct DatabaseHandler;
Expand description

Handler for reading and writing hash database files

Implementations§

Source§

impl DatabaseHandler

Source

pub fn checksum_algorithm_from_path(path: &Path) -> Option<Algorithm>

Infer a checksum algorithm from a path’s file extension.

Source

pub fn verification_checksum_algorithm( path: &Path, ) -> Result<Option<Algorithm>, HashUtilityError>

Check if a path corresponds to a supported checksum format for verification.

Source

pub fn read_checksum_manifest(path: &Path) -> Result<Manifest, HashUtilityError>

Read a conventional two-column checksum file for verification.

Source

pub fn canonical_output_path( requested_path: &Path, format: DatabaseFormat, compressed: bool, ) -> Result<PathBuf, HashUtilityError>

Return the canonical output path for a database.

Source

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.

Source

pub fn is_compressed(path: &Path) -> bool

Check if a path has .zst or .zstd extension (compressed database)

Source

pub fn compress_database(input_path: &Path) -> Result<PathBuf, HashUtilityError>

Compress a database file with Zstandard.

Source

pub fn detect_format(path: &Path) -> Result<DatabaseFormat, HashUtilityError>

Detect the format of a database file by reading its first few lines

Source

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

Source

pub fn write_hashdeep_header( writer: &mut impl Write, algorithms: &[String], ) -> Result<()>

Write hashdeep format header

Source

pub fn write_hashdeep_entry( writer: &mut impl Write, size: u64, hashes: &[String], path: &Path, ) -> Result<()>

Write a single entry in hashdeep format

Source

pub fn read_database( path: &Path, ) -> Result<HashMap<PathBuf, DatabaseEntry>, HashUtilityError>

Read a hash database file and parse it into a HashMap

Source

pub fn read_manifest(path: &Path) -> Result<Manifest, HashUtilityError>

Read every digest from a QuicHash or hashdeep manifest.

Source

pub fn read_manifest_with_policy( path: &Path, failure_policy: FailurePolicy, ) -> Result<ManifestRead, HashUtilityError>

Read a typed manifest, optionally retaining malformed-line issues.

Source

pub fn write_manifest( writer: &mut impl Write, manifest: &Manifest, format: DatabaseFormat, ) -> Result<()>

Write every manifest digest in QuicHash or hashdeep format.

Source

pub fn parse_line(line: &str) -> Option<(String, String, bool, PathBuf)>

Parse a single line from a QuicHash database file.

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.