pub struct FormatRegistry {
pub entries: BTreeMap<String, (Format, FormatSource)>,
pub types: TypeRegistry,
}Expand description
A named set of formats, each with its source, and the hole types the layers declared.
Fields§
§entries: BTreeMap<String, (Format, FormatSource)>The entries, by name.
types: TypeRegistryThe types the layers declared, the built-ins apart.
Implementations§
Source§impl FormatRegistry
impl FormatRegistry
Sourcepub fn from_text(
text: &str,
built_ins: &[(&str, &str)],
grammar: &Grammar,
regexes: &RegexCache,
) -> Result<Self>
pub fn from_text( text: &str, built_ins: &[(&str, &str)], grammar: &Grammar, regexes: &RegexCache, ) -> Result<Self>
A host’s embedded registry: the built-in types it adds, reserved as
the engine’s are, then the formats file text, whose entries are
embedded. A file that does not read is a defect of the build.
Sourcepub fn from_yaml(
registry: &Spanned,
source: FormatSource,
grammar: &Grammar,
regexes: &RegexCache,
) -> Result<Self, Vec<Finding>>
pub fn from_yaml( registry: &Spanned, source: FormatSource, grammar: &Grammar, regexes: &RegexCache, ) -> Result<Self, Vec<Finding>>
Build a registry from a registry map with no types of its own,
validating each entry against grammar format. Findings are on /.
Sourcepub fn from_yaml_at(
registry: &Spanned,
types: Option<&Spanned>,
source: FormatSource,
grammar: &Grammar,
regexes: &RegexCache,
path: &RepoPath,
base: Option<&FormatRegistry>,
) -> Result<Self, Vec<Finding>>
pub fn from_yaml_at( registry: &Spanned, types: Option<&Spanned>, source: FormatSource, grammar: &Grammar, regexes: &RegexCache, path: &RepoPath, base: Option<&FormatRegistry>, ) -> Result<Self, Vec<Finding>>
As from_yaml, with the layer’s types map, findings on path,
and the farther layers in base: an entry declaring patch is
merged onto the same-named entry of base before it is checked
(grammar format), and every template compiles against the types of
base with this layer’s on top.
Sourcepub fn layer(
registry: &Spanned,
types: Option<&Spanned>,
source: FormatSource,
grammar: &Grammar,
regexes: &RegexCache,
path: &RepoPath,
base: Option<&FormatRegistry>,
) -> (Self, Vec<Finding>)
pub fn layer( registry: &Spanned, types: Option<&Spanned>, source: FormatSource, grammar: &Grammar, regexes: &RegexCache, path: &RepoPath, base: Option<&FormatRegistry>, ) -> (Self, Vec<Finding>)
As from_yaml_at, keeping what loads beside the findings of what
does not: each type and format that fails is reported once, and
what uses it reports nothing more. A type that fails stands as one
that matches anything, so a template that names it still compiles;
a format that fails is left out.
Sourcepub fn types_seen(&self) -> TypeRegistry
pub fn types_seen(&self) -> TypeRegistry
The types a schema under this registry sees: the built-ins, then the layers’ own.
Sourcepub fn layered(&self, over: &FormatRegistry) -> FormatRegistry
pub fn layered(&self, over: &FormatRegistry) -> FormatRegistry
This registry with over on top: a same-named entry of over
replaces this one whole, and a same-named type likewise. An entry of
over that declared a patch was merged onto the farther one when it
was built. Where over declares types, this registry’s entries are
compiled again against them, so a type means one thing to every
format a schema sees.