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: u8; const EMPTY: Self; const ID: &str; // 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: u8

The fs-verity algorithm identifier (1 for SHA-256, 2 for SHA-512).

Source

const EMPTY: Self

An empty hash value with all bytes set to zero.

Source

const ID: &str

The algorithm identifier string (“sha256” or “sha512”).

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", so this trait is not object safe.

Implementors§

Source§

impl FsVerityHashValue for Sha256HashValue

Source§

const ALGORITHM: u8 = 1

Source§

const EMPTY: Self

Source§

const ID: &str = "sha256"

Source§

type Digest = CoreWrapper<CtVariableCoreWrapper<Sha256VarCore, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, OidSha256>>

Source§

impl FsVerityHashValue for Sha512HashValue

Source§

const ALGORITHM: u8 = 2

Source§

const EMPTY: Self

Source§

const ID: &str = "sha512"

Source§

type Digest = CoreWrapper<CtVariableCoreWrapper<Sha512VarCore, UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, OidSha512>>