pub struct HostSchemas { /* private fields */ }Expand description
The host modules one compilation may name: the ones the toolchain ships, plus any an embedder added.
The shipped tables answer for cove check on their own, and did so
alone until this existed: a module SHIPPED did not name was Unknown
to the checker and checked by the boundary and nothing else. An embedder
is not a lesser kind of host, though — embedding is why HostApi is a
trait — so a module it registers should be checked exactly as a shipped
one is, and the only thing missing was a way to hand its table over.
This is that way.
A custom module answers before a shipped one of the same name. An
embedding that replaces documents with an implementation of its own
registers a description of its own with it, and the description a run
enforces is the one the checker has to read: a checker reading the
shipped table there would be checking a module nothing is going to run.
A set built with HostSchemas::only answers for the modules it was
given and no others. That is for an embedding that registers a registry of
its own: a set that still fell back to SHIPPED would tell such a
program that files.write is a checked call, when the run it is about to
make has no files module to dispatch it to.
The tables are Copy and their contents are 'static, so this owns
only the list. Looking one up hands back the entry itself rather than a
borrow, which is what lets a caller hold a schema while it goes on
reading whatever it asked.
Implementations§
Source§impl HostSchemas
impl HostSchemas
Sourcepub fn new() -> HostSchemas
pub fn new() -> HostSchemas
The shipped modules and nothing else, which is what every command that is not an embedding reads.
Sourcepub fn only(schemas: impl IntoIterator<Item = ModuleSchema>) -> HostSchemas
pub fn only(schemas: impl IntoIterator<Item = ModuleSchema>) -> HostSchemas
Exactly the modules in schemas, with no fallback to SHIPPED.
This is what an embedding hands over when its registry is its own
rather than the shipped one plus additions. HostRegistry dispatches
only what was registered with it, so a checker that still read the
shipped tables would check files.write against a description of a
module the run has not got and report nothing, leaving the boundary’s
unknown host module to be the first mention of it — which is the
one failure moving schemas to the checker is meant to prevent.
A shipped module the embedding does register is described here the
same as any other: it is in schemas because the registry has it.
Sourcepub fn reads_shipped(&self) -> bool
pub fn reads_shipped(&self) -> bool
Whether a name this set was not given is answered from SHIPPED.
Sourcepub fn with(self, schema: ModuleSchema) -> HostSchemas
pub fn with(self, schema: ModuleSchema) -> HostSchemas
Adds schema, taking the set by value so a pipeline can be
configured in one expression.
Sourcepub fn insert(&mut self, schema: ModuleSchema)
pub fn insert(&mut self, schema: ModuleSchema)
Adds schema, replacing any module already added under that name.
Replacing rather than appending keeps one name to one description: two tables under one name would make every lookup depend on which was added first, which is the drift this crate exists to prevent.
Sourcepub fn module(&self, name: &str) -> Option<ModuleSchema>
pub fn module(&self, name: &str) -> Option<ModuleSchema>
The module name describes itself with, if this set has one.
A name that is not here is not an error: a host may register any module it likes, and a checker reading this says only that it cannot check what it was not shown.
Sourcepub fn custom(&self) -> &[ModuleSchema]
pub fn custom(&self) -> &[ModuleSchema]
Only the modules an embedder added.
Trait Implementations§
Source§impl Clone for HostSchemas
impl Clone for HostSchemas
Source§fn clone(&self) -> HostSchemas
fn clone(&self) -> HostSchemas
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for HostSchemas
impl Debug for HostSchemas
Source§impl Default for HostSchemas
impl Default for HostSchemas
Source§fn default() -> HostSchemas
fn default() -> HostSchemas
impl Eq for HostSchemas
Source§impl Extend<ModuleSchema> for HostSchemas
impl Extend<ModuleSchema> for HostSchemas
Source§fn extend<I: IntoIterator<Item = ModuleSchema>>(&mut self, schemas: I)
fn extend<I: IntoIterator<Item = ModuleSchema>>(&mut self, schemas: I)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl FromIterator<ModuleSchema> for HostSchemas
impl FromIterator<ModuleSchema> for HostSchemas
Source§fn from_iter<I: IntoIterator<Item = ModuleSchema>>(schemas: I) -> HostSchemas
fn from_iter<I: IntoIterator<Item = ModuleSchema>>(schemas: I) -> HostSchemas
Source§impl PartialEq for HostSchemas
impl PartialEq for HostSchemas
Source§fn eq(&self, other: &HostSchemas) -> bool
fn eq(&self, other: &HostSchemas) -> bool
self and other values to be equal, and is used by ==.