#[non_exhaustive]pub struct CanonicalRef {
pub source_type: SourceType,
pub source_id: String,
pub resolver_profile: String,
pub version: Option<String>,
}Expand description
Four-tuple audit identity of a fetched paper (ADR-0021 §1).
Two fetches of the same DOI through different resolvers (e.g.
Crossref vs. Unpaywall) produce two distinct CanonicalRef values
and therefore two distinct CanonicalRef::digest outputs. This is
the resolver-distinction the audit log uses to separate “fetched via
Crossref” from “fetched via Unpaywall” without changing the on-disk
filename derivation (which remains keyed on Ref via
crate::Safekey).
Marked #[non_exhaustive] per docs/PUBLIC_API.md §6 — adding new
fields in a future minor bump is non-breaking. External callers
construct values via Ref::promote or CanonicalRef::new, not
by struct-literal.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.source_type: SourceTypeIdentifier class (DOI / arXiv / future).
source_id: StringValidated identifier string ("10.1234/foo", "2401.12345").
resolver_profile: StringResolver key that produced this audit identity. One of the
existing resolver keys ("crossref", "unpaywall", "arxiv",
"oa-publisher") plus future ones ("openalex", "s2", …).
version: Option<String>Optional version (arXiv "v2", Crossref-snapshot date). When
None, the digest treats this field as the empty byte sequence
(ADR-0021 §1 Slice 2 clarification — no sentinel).
Implementations§
Source§impl CanonicalRef
impl CanonicalRef
Sourcepub fn new(
source_type: SourceType,
source_id: impl Into<String>,
resolver_profile: impl Into<String>,
version: Option<String>,
) -> Self
pub fn new( source_type: SourceType, source_id: impl Into<String>, resolver_profile: impl Into<String>, version: Option<String>, ) -> Self
Construct a new CanonicalRef from its four fields.
The struct is #[non_exhaustive]; external code MUST use this
constructor (or Ref::promote) rather than a struct literal.
Sourcepub fn digest(&self) -> [u8; 32]
pub fn digest(&self) -> [u8; 32]
Compute the canonical-digest per ADR-0021 §1.
SHA256( source_type | 0x00 | source_id | 0x00
| resolver_profile | 0x00 | version_or_empty )version_or_empty is the empty byte sequence when
Self::version is None (ADR-0021 §1 NORMATIVE clarification
— no "null" / "none" / "-" sentinel).
Sourcepub fn digest_hex(&self) -> String
pub fn digest_hex(&self) -> String
Hex-encoded Self::digest — 64 lowercase ASCII hex chars.
Trait Implementations§
Source§impl Clone for CanonicalRef
impl Clone for CanonicalRef
Source§fn clone(&self) -> CanonicalRef
fn clone(&self) -> CanonicalRef
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more