Skip to main content

FsVerityHashValue

Trait FsVerityHashValue 

Source
pub trait FsVerityHashValue
where Self: Clone + From<Output<Self::Digest>> + FromBytes + Immutable + IntoBytes + KnownLayout + Unaligned + Hash + Eq + Debug + Send + Sync + Unpin + 'static,
{ type Digest: Digest + FixedOutputReset + Debug; const ALGORITHM: Algorithm; const EMPTY: Self; // Provided methods fn from_hex(hex: impl AsRef<[u8]>) -> Result<Self, FromHexError> { ... } fn from_object_dir_and_basename( dirnum: u8, basename: impl AsRef<[u8]>, ) -> Result<Self, FromHexError> { ... } fn from_object_pathname( pathname: impl AsRef<[u8]>, ) -> Result<Self, FromHexError> { ... } fn to_object_pathname(&self) -> String { ... } fn to_object_dir(&self) -> String { ... } fn to_hex(&self) -> String { ... } fn to_id(&self) -> String { ... } }
Expand description

Trait for fs-verity hash value types supporting SHA-256 and SHA-512.

This trait defines the interface for hash values used in fs-verity operations, including serialization to/from hex strings and object store pathnames.

Required Associated Constants§

Source

const ALGORITHM: Algorithm

The fs-verity algorithm for this hash type.

Source

const EMPTY: Self

An empty hash value with all bytes set to zero.

Required Associated Types§

Source

type Digest: Digest + FixedOutputReset + Debug

The underlying hash digest algorithm type.

Provided Methods§

Source

fn from_hex(hex: impl AsRef<[u8]>) -> Result<Self, FromHexError>

Parse a hash value from a hexadecimal string.

§Arguments
  • hex - A hexadecimal string representation of the hash
§Returns

The parsed hash value, or an error if the input is invalid.

Source

fn from_object_dir_and_basename( dirnum: u8, basename: impl AsRef<[u8]>, ) -> Result<Self, FromHexError>

Parse a hash value from an object store directory number and basename.

Object stores typically use a two-level hierarchy where the first byte of the hash determines the directory name and the remaining bytes form the basename.

§Arguments
  • dirnum - The directory number (first byte of the hash)
  • basename - The hexadecimal basename (remaining bytes)
§Returns

The parsed hash value, or an error if the input is invalid.

Source

fn from_object_pathname( pathname: impl AsRef<[u8]>, ) -> Result<Self, FromHexError>

Parse a hash value from a full object pathname.

Parses a pathname in the format “xx/yyyyyy” where “xxyyyyyy” is the full hexadecimal hash. The prefix before the two-level hierarchy is ignored.

§Arguments
  • pathname - The object pathname (e.g., “ab/cdef1234…”)
§Returns

The parsed hash value, or an error if the input is invalid.

Source

fn to_object_pathname(&self) -> String

Convert the hash value to an object pathname.

Formats the hash as “xx/yyyyyy” where xx is the first byte in hex and yyyyyy is the remaining bytes in hex.

§Returns

A string in object pathname format.

Source

fn to_object_dir(&self) -> String

Convert the hash value to an object directory name.

Returns just the first byte of the hash as a two-character hex string.

§Returns

A string representing the directory name.

Source

fn to_hex(&self) -> String

Convert the hash value to a hexadecimal string.

§Returns

The full hash as a hex string.

Source

fn to_id(&self) -> String

Convert the hash value to an identifier string with algorithm prefix.

§Returns

A string in the format “algorithm:hexhash” (e.g., “sha256:abc123…”).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§