Skip to main content

HostSchemas

Struct HostSchemas 

Source
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

Source

pub fn new() -> HostSchemas

The shipped modules and nothing else, which is what every command that is not an embedding reads.

Source

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.

Source

pub fn reads_shipped(&self) -> bool

Whether a name this set was not given is answered from SHIPPED.

Source

pub fn with(self, schema: ModuleSchema) -> HostSchemas

Adds schema, taking the set by value so a pipeline can be configured in one expression.

Source

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.

Source

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.

Source

pub fn custom(&self) -> &[ModuleSchema]

Only the modules an embedder added.

Source

pub fn names(&self) -> impl Iterator<Item = &'static str>

Every module name this set answers for, added ones first.

A custom module that takes a shipped module’s name is named once: it is one module, described by whichever table answers for it.

Trait Implementations§

Source§

impl Clone for HostSchemas

Source§

fn clone(&self) -> HostSchemas

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for HostSchemas

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for HostSchemas

Source§

fn default() -> HostSchemas

Returns the “default value” for a type. Read more
Source§

impl Eq for HostSchemas

Source§

impl Extend<ModuleSchema> for HostSchemas

Source§

fn extend<I>(&mut self, schemas: I)
where I: IntoIterator<Item = ModuleSchema>,

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl FromIterator<ModuleSchema> for HostSchemas

Source§

fn from_iter<I>(schemas: I) -> HostSchemas
where I: IntoIterator<Item = ModuleSchema>,

Creates a value from an iterator. Read more
Source§

impl PartialEq for HostSchemas

Source§

fn eq(&self, other: &HostSchemas) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for HostSchemas

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.