pub struct Catalog {
pub schema_version: u32,
pub locales: Vec<Locale>,
pub target: TargetMeta,
pub provenance: Provenance,
/* private fields */
}Expand description
The validated canonical Workshop catalog.
Fields§
§schema_version: u32§locales: Vec<Locale>The declared locales, normalized; the first one is the primary locale and must be fully covered.
target: TargetMeta§provenance: ProvenanceImplementations§
Source§impl Catalog
impl Catalog
Sourcepub fn load(json: &str) -> Result<Catalog, WorkshopError>
pub fn load(json: &str) -> Result<Catalog, WorkshopError>
Parse and validate catalog data, verifying the declared content digest when the data carries one.
Sourcepub fn load_unverified(json: &str) -> Result<Catalog, WorkshopError>
pub fn load_unverified(json: &str) -> Result<Catalog, WorkshopError>
Parse and validate catalog data without digest verification. Used by
the catalog pipeline so a stale digest can be repaired by build.
Sourcepub fn builtin() -> Result<Catalog, WorkshopError>
pub fn builtin() -> Result<Catalog, WorkshopError>
The built-in catalog data.
Sourcepub fn locales(&self) -> &[Locale]
pub fn locales(&self) -> &[Locale]
The declared locales, normalized; the first one is the primary locale.
Sourcepub fn primary_locale(&self) -> &Locale
pub fn primary_locale(&self) -> &Locale
The primary locale: the first declared one, whose mapping surface is
complete (en-US in the committed catalog).
Sourcepub fn catalog_version(&self) -> &str
pub fn catalog_version(&self) -> &str
The catalog dataset version (ADR-0001 catalog-version).
Sourcepub fn catalog_digest(&self) -> Option<&str>
pub fn catalog_digest(&self) -> Option<&str>
The declared content digest (sha256 hex) of the catalog dataset,
verified at load; None for data that declares none.
Sourcepub fn implementation_version() -> &'static str
pub fn implementation_version() -> &'static str
The workshop-rs package version (ADR-0001 implementation-version).
Sourcepub fn identity(&self) -> CatalogIdentity
pub fn identity(&self) -> CatalogIdentity
The machine-readable catalog identity: implementation version, catalog version + digest, locale coverage, target evidence, and provenance.
Sourcepub fn locale_coverage(&self, locale: &Locale) -> LocaleCoverage
pub fn locale_coverage(&self, locale: &Locale) -> LocaleCoverage
The mapping coverage of one declared locale: mapped entries out of the declared total (builtins and enum members). The primary locale is always complete; other locales may be partially covered.
Sourcepub fn locale_coverage_all(&self) -> Vec<LocaleCoverage>
pub fn locale_coverage_all(&self) -> Vec<LocaleCoverage>
The mapping coverage of every declared locale, in declaration order.
Sourcepub fn entry(&self, kind: Kind, id: &str) -> Option<&CatalogEntry>
pub fn entry(&self, kind: Kind, id: &str) -> Option<&CatalogEntry>
The builtin with the given canonical id and kind.
Sourcepub fn resolve(
&self,
kind: Kind,
locale: &Locale,
spelling: &str,
) -> Option<&CatalogEntry>
pub fn resolve( &self, kind: Kind, locale: &Locale, spelling: &str, ) -> Option<&CatalogEntry>
Resolve a localized spelling to its canonical builtin.
Sourcepub fn spelling(&self, kind: Kind, locale: &Locale, id: &str) -> Option<&str>
pub fn spelling(&self, kind: Kind, locale: &Locale, id: &str) -> Option<&str>
The localized spelling of a canonical builtin id.
Sourcepub fn entries_of(&self, kind: Kind) -> impl Iterator<Item = &CatalogEntry>
pub fn entries_of(&self, kind: Kind) -> impl Iterator<Item = &CatalogEntry>
Every entry of a kind, in catalog order.
Sourcepub fn entry_count(&self) -> usize
pub fn entry_count(&self) -> usize
The total number of builtin entries.
Sourcepub fn enum_domains_count(&self) -> usize
pub fn enum_domains_count(&self) -> usize
The number of enum domains.
Sourcepub fn enum_domain(&self, domain: &str) -> Option<&EnumDomain>
pub fn enum_domain(&self, domain: &str) -> Option<&EnumDomain>
The enum domain with the given name.
Sourcepub fn resolve_enum_domain(
&self,
locale: &Locale,
spelling: &str,
) -> Option<&str>
pub fn resolve_enum_domain( &self, locale: &Locale, spelling: &str, ) -> Option<&str>
Resolve a localized enum-domain spelling to its canonical domain id.
Sourcepub fn enum_domains(&self) -> impl Iterator<Item = &EnumDomain>
pub fn enum_domains(&self) -> impl Iterator<Item = &EnumDomain>
Every enum domain, in catalog order.
Sourcepub fn resolve_enum_member(
&self,
domain: &str,
locale: &Locale,
spelling: &str,
) -> Option<(String, String)>
pub fn resolve_enum_member( &self, domain: &str, locale: &Locale, spelling: &str, ) -> Option<(String, String)>
Resolve a localized enum member spelling to (domain, canonical member).
Sourcepub fn enum_spelling(
&self,
domain: &str,
locale: &Locale,
member: &str,
) -> Option<&str>
pub fn enum_spelling( &self, domain: &str, locale: &Locale, member: &str, ) -> Option<&str>
The localized spelling of a canonical enum member.
Sourcepub fn bare_member_matches(
&self,
locale: &Locale,
spelling: &str,
) -> Vec<(String, String)>
pub fn bare_member_matches( &self, locale: &Locale, spelling: &str, ) -> Vec<(String, String)>
Every (domain, canonical member) match for a bare (domain-less)
localized member spelling. Returns all matches so callers can report
ambiguity; a well-formed catalog has at most one meaningful match for
a given spelling.
Trait Implementations§
Source§impl ExpectedDomain for Catalog
The catalog is the canonical source of expected enum domains for the
Workshop surface it documents: expected_domain(catalog_id, arg_index)
answers the domain declared for that parameter position (e.g. createHudText
argument 9 is HudReeval), so the Workshop parser can resolve bare enum
members that are ambiguous across domains (e.g. Visible To and String).
Positions without a documented domain answer None.
impl ExpectedDomain for Catalog
The catalog is the canonical source of expected enum domains for the
Workshop surface it documents: expected_domain(catalog_id, arg_index)
answers the domain declared for that parameter position (e.g. createHudText
argument 9 is HudReeval), so the Workshop parser can resolve bare enum
members that are ambiguous across domains (e.g. Visible To and String).
Positions without a documented domain answer None.