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<FormatRegistry, Error>
pub fn from_text( text: &str, built_ins: &[(&str, &str)], grammar: &Grammar, regexes: &RegexCache, ) -> Result<FormatRegistry, Error>
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<FormatRegistry, Vec<Finding>>
pub fn from_yaml( registry: &Spanned, source: FormatSource, grammar: &Grammar, regexes: &RegexCache, ) -> Result<FormatRegistry, 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<FormatRegistry, Vec<Finding>>
pub fn from_yaml_at( registry: &Spanned, types: Option<&Spanned>, source: FormatSource, grammar: &Grammar, regexes: &RegexCache, path: &RepoPath, base: Option<&FormatRegistry>, ) -> Result<FormatRegistry, 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>,
) -> (FormatRegistry, Vec<Finding>)
pub fn layer( registry: &Spanned, types: Option<&Spanned>, source: FormatSource, grammar: &Grammar, regexes: &RegexCache, path: &RepoPath, base: Option<&FormatRegistry>, ) -> (FormatRegistry, 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, Vec<BrokenFormat>)
pub fn layered( &self, over: &FormatRegistry, ) -> (FormatRegistry, Vec<BrokenFormat>)
This registry with over on top, and each format of this registry
that no longer compiles against the types of over: 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 a type that
differs from this registry’s, each entry that uses it is compiled
again against it, so a type means one thing to every format a schema
sees, and an entry that no longer compiles is left out, so the engine
checks no line against its old compile.
Sourcepub fn with_packs(&self, files: &[(RepoPath, FormatRegistry)]) -> PackLayer
pub fn with_packs(&self, files: &[(RepoPath, FormatRegistry)]) -> PackLayer
This registry, the shared layer, with the pack layer on top: the
entries and the types of files, each a formats file of the layer
built with layer on this registry with the source
FormatSource::Pack. The files are read in the order of their
paths, whatever order the caller gives, so no entry patches another
file’s; where two files define one name, the entry of the first
stands, and the layer keeps the clash for PackLayer::with_host.
Each format that uses a type of the layer is compiled again against
it, so a type means one thing to every format that a schema sees. A
format of a file that no longer compiles is left out and reported on
that file. A format of this registry that no longer compiles stays
as this registry compiled it, for the host’s layer to settle, and
PackLayer::with_host reports it where the host’s layer leaves it
broken.
Trait Implementations§
Source§impl Clone for FormatRegistry
impl Clone for FormatRegistry
Source§fn clone(&self) -> FormatRegistry
fn clone(&self) -> FormatRegistry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more