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: StringThe chain label. Canonical value is chia; mainnet/testnet are accepted for back-compat.
store_id: Bytes32The 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
impl DigUrn
Sourcepub fn parse(input: &str) -> Result<DigUrn, UrnParseError>
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.
Sourcepub fn parse_with_salt(
input: &str,
) -> Result<(DigUrn, Option<String>), UrnParseError>
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.
Sourcepub fn salt_bytes(salt_hex: &str) -> Result<SecretSalt, UrnParseError>
pub fn salt_bytes(salt_hex: &str) -> Result<SecretSalt, UrnParseError>
Validate a peeled salt hex string into a SecretSalt — exactly 32 bytes / 64 hex.
Sourcepub fn effective_resource_key(&self) -> &str
pub fn effective_resource_key(&self) -> &str
The resource path, defaulting an absent or empty key to DEFAULT_RESOURCE_KEY.
Sourcepub fn canonical_rootless(&self) -> DigUrn
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).
Sourcepub fn retrieval_key(&self) -> Bytes32
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.
Sourcepub fn retrieval_key_hex(&self) -> String
pub fn retrieval_key_hex(&self) -> String
retrieval_key as lowercase hex.
Sourcepub fn content_key(&self) -> Bytes32
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.
Sourcepub fn content_key_hex(&self) -> String
pub fn content_key_hex(&self) -> String
content_key as lowercase hex.
Sourcepub fn store_id_hex(&self) -> String
pub fn store_id_hex(&self) -> String
The store id as lowercase hex.