pub struct Catalog { /* private fields */ }Expand description
The validated canonical Workshop catalog.
Implementations§
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.
Source§impl Catalog
impl Catalog
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, localized preset identities, 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 resolve_localized_string(
&self,
locale: &Locale,
spelling: &str,
) -> Option<&LocalizedStringEntry>
pub fn resolve_localized_string( &self, locale: &Locale, spelling: &str, ) -> Option<&LocalizedStringEntry>
Resolve a localized preset spelling to its stable identity.
Sourcepub fn localized_string_spelling(
&self,
locale: &Locale,
id: &str,
) -> Option<&str>
pub fn localized_string_spelling( &self, locale: &Locale, id: &str, ) -> Option<&str>
Resolve the emitted spelling of a localized preset identity.
Sourcepub fn localized_strings(&self) -> impl Iterator<Item = &LocalizedStringEntry>
pub fn localized_strings(&self) -> impl Iterator<Item = &LocalizedStringEntry>
Every reviewed localized preset identity, 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 localized_enum_spelling(
&self,
domain: &str,
locale: &Locale,
member: &str,
) -> Option<&str>
pub fn localized_enum_spelling( &self, domain: &str, locale: &Locale, member: &str, ) -> Option<&str>
Resolve a canonical enum member through the locale boundary, including reviewed partial locale spellings that are not yet part of the full catalog locale set.
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.
Source§impl Catalog
impl Catalog
Sourcepub fn lookup(
&self,
locale: &Locale,
query: &str,
) -> Result<Vec<LookupMatch>, WorkshopError>
pub fn lookup( &self, locale: &Locale, query: &str, ) -> Result<Vec<LookupMatch>, WorkshopError>
Find canonical constructs matching query under locale.
query may be a display name in locale, a primary-locale display
name, a canonical id, a near spelling or guess, or a settings path
prefix (gamemodes.control, heroes.<team>.<hero>). Matches rank
exact spellings first, then near spellings, token prefixes, and
substring guesses; ties keep catalog and table order. All matches are
canonical constructs the parser and emitter accept, with the display
name in locale and, for actions and values, the compact signature.
An empty result reports that nothing matched. Err reports a query
the catalog cannot answer: a locale the catalog does not declare.
use workshop_rs::catalog::{Catalog, Locale};
use workshop_rs::lookup::LookupMatch;
let catalog = Catalog::builtin().unwrap();
let matches = catalog.lookup(&Locale::new("en-US"), "create hud txt").unwrap();
assert!(matches.iter().any(|m| matches!(
m,
LookupMatch::Builtin { id, .. } if id == "createHudText"
)));Sourcepub fn lookup_within(
&self,
locale: &Locale,
within: &str,
query: Option<&str>,
) -> Result<Vec<LookupMatch>, WorkshopError>
pub fn lookup_within( &self, locale: &Locale, within: &str, query: Option<&str>, ) -> Result<Vec<LookupMatch>, WorkshopError>
The entries within contains under locale — the members of an
enum domain, the parameters of a callable, or the settings keys
and segments under a path prefix — optionally filtered and ranked
by query with the same matcher an unscoped Catalog::lookup
uses.
within resolves in a fixed order: an enum domain (catalog or
settings-table), an action or value id or locale spelling, then
a settings path prefix. Template segments (<team>, <hero>)
accept their own template spelling or a canonical team/hero key
the settings table recognizes — never an arbitrary value — so a
literal path stays literal (heroes.general lists only the
general group’s children). With no query, or an
empty one, children keep the scope’s own order — domain order for
members, call order for parameters, table order for settings — and
a non-empty query filters and ranks them by the same scoring an
unscoped lookup applies to its candidates.
Err reports a locale the catalog does not declare or a within
naming no known scope; an empty result reports a scope whose
children do not match query.
use workshop_rs::catalog::{Catalog, Locale};
use workshop_rs::lookup::LookupMatch;
let catalog = Catalog::builtin().unwrap();
let members = catalog
.lookup_within(&Locale::new("en-US"), "Team", None)
.unwrap();
assert!(members.iter().all(|m| matches!(m, LookupMatch::EnumMember { domain, .. } if domain == "Team")));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.