Skip to main content

DigUrn

Struct DigUrn 

Source
pub struct DigUrn {
    pub chain: String,
    pub store_id: Bytes32,
    pub root_hash: Option<Bytes32>,
    pub resource_key: Option<String>,
}
Expand description

A parsed DIG URN.

The resource_key distinguishes three states: None (absent — a bare store/root URN), Some("") (a trailing slash), and Some("path") (a concrete resource). All three are valid; DigUrn::effective_resource_key maps the first two to the DEFAULT_RESOURCE_KEY.

Fields§

§chain: String

The chain label. Canonical value is chia; mainnet/testnet are accepted for back-compat.

§store_id: Bytes32

The CHIP-0035 singleton launcher id (store identity).

§root_hash: Option<Bytes32>

The pinned on-chain generation root. None = the root-independent form. The root is the trust anchor for inclusion verification ONLY; it is never a key input.

§resource_key: Option<String>

The resource path within the store, verbatim after the FIRST /. See the struct docs for the three-state distinction.

Implementations§

Source§

impl DigUrn

Source

pub fn parse(input: &str) -> Result<DigUrn, UrnParseError>

Parse a canonical URN string (no ?salt= handling — use DigUrn::parse_with_salt to peel a salt suffix first). Accepts an omitted root-hash and/or resource.

Source

pub fn parse_with_salt( input: &str, ) -> Result<(DigUrn, Option<String>), UrnParseError>

Parse a URN, peeling an OPTIONAL ?salt=<hex> suffix off the tail first.

The salt is validated as non-empty hex (case-insensitive, normalised to lowercase) and returned separately; the remainder is parsed by DigUrn::parse. A conforming validator that surfaces the salt MUST require exactly 64 hex chars — this function accepts any non-empty hex and leaves the 32-byte enforcement to DigUrn::salt_bytes.

Source

pub fn salt_bytes(salt_hex: &str) -> Result<SecretSalt, UrnParseError>

Validate a peeled salt hex string into a SecretSalt — exactly 32 bytes / 64 hex.

Source

pub fn canonical(&self) -> String

Render the canonical URN string.

Source

pub fn effective_resource_key(&self) -> &str

The resource path, defaulting an absent or empty key to DEFAULT_RESOURCE_KEY.

Source

pub fn canonical_rootless(&self) -> DigUrn

The canonical ROOT-INDEPENDENT resource URN. Dropping the root keeps the retrieval and decryption keys stable across generations (matching the host/CLI commit-time derivation), and carries the DigUrn::effective_resource_key (empty/absent → index.html).

Source

pub fn retrieval_key(&self) -> Bytes32

The URN-identity retrieval key: SHA-256(canonical()) — over the FULL canonical form (including the pinned root, if any). This is the value the frozen conformance corpus pins and that digstore_core::Urn::retrieval_key derives; it is a property of the URN string.

Source

pub fn retrieval_key_hex(&self) -> String

retrieval_key as lowercase hex.

Source

pub fn content_key(&self) -> Bytes32

The ROOT-INDEPENDENT content key: SHA-256(canonical_rootless()). Stable across generations, it is the identifier a resolver uses to FETCH content and the seed for the AES key derivation (matching the host/CLI commit-time derivation) — distinct from DigUrn::retrieval_key, which pins the root.

Source

pub fn content_key_hex(&self) -> String

content_key as lowercase hex.

Source

pub fn store_id_hex(&self) -> String

The store id as lowercase hex.

Source

pub fn root_hex(&self) -> Option<String>

The pinned generation root as lowercase hex, if the URN carries one.

Trait Implementations§

Source§

impl Clone for DigUrn

Source§

fn clone(&self) -> DigUrn

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DigUrn

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for DigUrn

Source§

impl PartialEq for DigUrn

Source§

fn eq(&self, other: &DigUrn) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for DigUrn

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.