Skip to main content

Model

Struct Model 

Source
pub struct Model {
    pub knowledges: Vec<Knowledge>,
    pub additional: Vec<AdditionalFile>,
    pub dispatch: BTreeMap<RepoPath, Option<SchemaRef>>,
    pub tree: Tree,
    pub problems: Vec<Finding>,
    pub reads: Recorder,
    pub fallback: Option<Box<dyn Fallback>>,
    pub markers: BTreeMap<RepoPath, Vec<MarkerRow>>,
    pub marker_check: MarkerCheck,
    pub plans: PlanIndex,
    pub chains: Chains,
    /* private fields */
}
Expand description

A Model holds every knowledge store, every additional file, and the tree.

Fields§

§knowledges: Vec<Knowledge>

The knowledge stores, in configuration order.

§additional: Vec<AdditionalFile>

The additional files that the run has loaded, by path.

§dispatch: BTreeMap<RepoPath, Option<SchemaRef>>

Each additional file that a schema’s globs match, by path, whether the run has loaded it or not. The value is the schema whose glob matches the file, or none when the globs of more than one schema match it (CACHE-1_AC-15).

§tree: Tree

The walked tree.

§problems: Vec<Finding>

The findings of the build, such as files that fail to load and globs that clash.

§reads: Recorder

The reads of the run. The recorder keeps each query that the check of a file makes, under the path of that file (CACHE-1_AC-4).

§fallback: Option<Box<dyn Fallback>>

The cache. It supplies facts about the documents that the run did not load (CACHE-1_AC-21).

§markers: BTreeMap<RepoPath, Vec<MarkerRow>>

The markers of each file outside the knowledge roots that the run has loaded, by path. The markers come from a scan of the file, or from the rows that the cache keeps for it.

§marker_check: MarkerCheck

What the run does with markers. It is Off until a check sets it.

§plans: PlanIndex

plans holds the files that the documents plan (SOKF_SCHEMA_53).

§chains: Chains

chains holds the chain of extends of each store, resolved when the model is built (SOKF_SCHEMA_96).

Implementations§

Source§

impl Model

Source

pub fn is_archived( &self, knowledge: usize, type_name: Option<&str>, frontmatter: Option<&Spanned>, ) -> bool

is_archived returns whether a document of store knowledge is archived, from its type and its frontmatter, as archived_documents decides it.

Source

pub fn archived_documents(&self) -> BTreeSet<RepoPath>

archived_documents returns the archived documents of every store. For each document that this run loaded, it reads the frontmatter to decide whether the document is archived. For every other document, it reads the store’s rows.

Source§

impl Model

Source

pub fn own_roots(&self) -> usize

own_roots returns the number of own stores, those of knowledge.roots, which come before the registered ones (CLI-6_AC-116).

Source

pub fn broken(&self, k: usize) -> Option<&Broken>

broken returns why store k has no chain of extends, or None when it has one.

Source

pub fn in_broken_store(&self, path: &RepoPath) -> bool

in_broken_store returns whether path lies in a store whose extends is broken, whose files no check and no fix touches (FORMAT-5_AC-10).

Source

pub fn inherited(&self, k: usize) -> Vec<SchemaRef>

inherited returns each schema that store k inherits.

Source

pub fn claimants(&self, k: usize, type_name: &str) -> Vec<SchemaRef>

claimants returns the schemas that govern type_name in store k, through the chain of extends. It records the schema query of each store that it reads, so that a schema that a store of the chain adds, removes, or changes makes the reader dirty (CACHE-1_AC-15).

Source

pub fn declares(&self, k: usize, type_name: &str) -> bool

declares returns whether store k declares type_name, in a schema of its own or in one that it inherits (CLI-6_AC-117).

Source§

impl Model

Source

pub fn watch(&self, reader: &RepoPath)

watch records every later read against reader.

Source

pub fn unwatch(&self)

unwatch stops recording reads against any reader.

Source

pub fn note(&self, query: Query)

note records query against the watched reader.

Source

pub fn reads_of(&self, reader: &RepoPath) -> BTreeSet<Query>

reads_of returns the queries that reader made.

Source

pub fn reads(&self) -> BTreeMap<RepoPath, BTreeSet<Query>>

reads returns the queries of every reader.

Source

pub fn document(&self, knowledge: usize, id: &str) -> Option<&Document>

document returns the document with id in knowledge, when the run has loaded it. Before the checks run, the run loads every document that a check looks up. If only the cache knows a document, the run failed to load it, so a debug build stops with an assertion failure.

Source

pub fn ids(&self, knowledge: usize, id: &str) -> Vec<RepoPath>

ids returns the path of every document and schema of knowledge that has id. It takes the paths from the documents that the run has loaded. It then adds each path that the cache knows, unless the run has loaded it.

Source

pub fn documents_of(&self, knowledge: usize, type_name: &str) -> Vec<&Document>

documents_of returns the documents of type type_name in knowledge that the run has loaded.

Source

pub fn ids_of_type( &self, knowledge: usize, type_name: &str, ) -> Vec<(RepoPath, String)>

ids_of_type returns the path and id of every document of type type_name in knowledge. It takes them from the documents that the run has loaded. For the paths that the run has not loaded, it adds the cache’s rows.

Source

pub fn path_of_id(&self, knowledge: usize, id: &str) -> Option<RepoPath>

path_of_id returns the path of the document or schema with id in knowledge, when exactly one document or schema has it. It counts the documents that the run has loaded and the ones that the cache knows (CACHE-1_AC-21).

Source

pub fn id_of(&self, path: &RepoPath) -> Option<(usize, String)>

id_of returns the knowledge store and id of the document or schema at path. It takes them from the document when the run has loaded it, and from the cache’s row for the path otherwise.

Source

pub fn broken_in(&self, knowledge: usize) -> Vec<RepoPath>

broken_in returns the paths of the documents of knowledge whose frontmatter doesn’t parse. It takes them from the documents that the run has loaded. For the documents that the run has not loaded, it adds the paths that the cache lists as broken.

Source

pub fn holds(&self, path: &RepoPath) -> bool

holds reports whether the run has loaded a document or schema at path.

Source

pub fn is_document(&self, path: &RepoPath) -> bool

is_document reports whether path is a document of any knowledge store, whether the run has loaded it or only the cache knows it.

Source

pub fn admit(&mut self, knowledge: usize, doc: Document)

admit adds to the model a document that the build did not load. The run has since read the document in full. Such a document is one that the run checks, or one that a check looks up.

Source

pub fn admit_schema(&mut self, knowledge: usize, schema: SchemaDocument)

admit_schema replaces the cache’s summary of a schema with the schema read in full. It keeps the same index, so every reference to the schema stays valid (CACHE-1_AC-25).

Source

pub fn admit_index(&mut self, knowledge: usize, index: IndexFile)

admit_index adds to the model an index file that the build did not load. The run reads the index file of a directory when a change touches the directory, so that the check of the directory can compare it with the expected index (CACHE-1_AC-18).

Source

pub fn exists(&self, path: &RepoPath) -> bool

exists reports whether path is a file or a directory of the repository, and records the question as a query (CACHE-1_AC-26).

Source

pub fn is_dir(&self, path: &RepoPath) -> bool

is_dir reports whether path is a directory of the repository, and records the question as the query of exists.

Source

pub fn by_path(&self, path: &RepoPath) -> Option<Located<'_>>

by_path returns what path is in the model.

Source

pub fn is_document_of(&self, knowledge: usize, path: &RepoPath) -> bool

is_document_of reports whether path is a document of knowledge.

Source

pub fn is_materialized(&self, path: &RepoPath) -> bool

is_materialized reports whether path is a document of any knowledge store or an additional file. An include block that refers to a file by path can’t include such a file.

Source

pub fn is_additional(&self, path: &RepoPath) -> bool

is_additional reports whether a schema’s globs match path as an additional file, whether the run has loaded it or not.

Source

pub fn admit_additional(&mut self, file: AdditionalFile)

admit_additional adds to the model an additional file that the build did not load. The run has since read the file in full, because a check needs it (CACHE-1_AC-20).

Source

pub fn is_materialized_in( &self, knowledge: Option<usize>, path: &RepoPath, ) -> bool

is_materialized_in reports whether path is a document of knowledge or an additional file that its schemas match. An include block in a document of knowledge can’t include such a file by path (SOKF_FORMAT_89). is_materialized_in treats an additional file of another knowledge store as an ordinary repository file, which such an include block can include. With no knowledge store given, the files of every knowledge store count. To reject an include block that refers by path to a document or an asset of any knowledge store, a caller checks the path separately, through id_at and asset_at.

Source

pub fn asset_of(&self, sidecar: &RepoPath) -> Option<(usize, &Asset)>

asset_of returns the asset that the document at sidecar describes, with its knowledge store.

Source

pub fn asset_at(&self, path: &RepoPath) -> Option<(usize, &Asset)>

asset_at returns the asset at path, with its knowledge store.

Source

pub fn content_path(&self, document: &RepoPath) -> RepoPath

content_path returns the path that the id of a document refers to (FORMAT-2_AC-1): the path of the asset for a sidecar, and the path of the document otherwise. The resolution of an id doesn’t change: an id still resolves to its document. Only code that needs the content calls content_path. For example, the code that builds the definition of a label without a fragment calls it.

Source

pub fn schema(&self, r: SchemaRef) -> &SchemaDocument

schema returns the schema at r.

Source

pub fn schema_query(&self, r: SchemaRef) -> Query

schema_query returns the query that stands for a read of the schema at r. The query uses the key that schema_key returns. The key is the value of the schema’s type const, or, for a schema that dispatches only by its globs, the schema’s path (CACHE-1_AC-15).

Source

pub fn knowledge_of(&self, path: &RepoPath) -> Option<usize>

knowledge_of returns the knowledge store whose root contains path, the innermost one when roots nest.

Source

pub fn is_unit(&self, path: &RepoPath) -> bool

is_unit reports whether path is a unit. A unit is a file that a check produces output for: a document, a schema document, or an additional file matched by a schema’s globs (CACHE-1_AC-24). It searches the walk’s sorted list, so it does not build a set of all paths.

Source

pub fn is_marker_file(&self, path: &RepoPath) -> bool

is_marker_file reports whether path is a file that the run reads for markers: a file of the walk outside every knowledge root, when the run checks markers (SOKF_VALIDATION_50).

Source

pub fn document_paths(&self) -> BTreeSet<RepoPath>

document_paths returns the path of every document and schema document of every knowledge store that the walk lists, whether the run has loaded it or not. These are the files that a full run reads.

Source

pub fn documents(&self) -> impl Iterator<Item = (usize, &Document)>

documents returns every document of every knowledge store, with the index of its knowledge store.

Source

pub fn documents_and_schemas(&self) -> impl Iterator<Item = (usize, &Document)>

documents_and_schemas returns every document and every schema document of every knowledge store, with the index of its knowledge store.

Source§

impl Model

Source

pub fn is_planned(&self, path: &RepoPath) -> bool

is_planned reports whether a document plans a file at path, and records the query for path and for each directory above it, so that the reader is checked again when the plan of the path or of a directory that holds it changes.

Source§

impl Model

Source

pub fn identity_rows(&self) -> Vec<IdentityRow>

identity_rows returns the current and former identities of every store, in the form that the cache compares (CACHE-1_AC-16).

Source

pub fn store(&self, citing: usize, written: &str) -> Option<StoreHit>

store finds the store that written refers to from a document of store citing (SOKF_FORMAT_64). It looks up a name among the stores in the scope of the citing store, and a scope/name among every store. It matches the current identities first, then the former ones. When two stores share an identity, store returns None, because validation reports that clash on their manifests.

store records a single dependency on the identities of all stores (CACHE-1_AC-16), not one for each store it reads. A finer dependency would save little, for two reasons. Renaming a store changes every qualified id that refers to the store, and few documents need store.

Source

pub fn stores_named(&self, written: &str) -> Vec<usize>

stores_named returns the stores that written names on the command line, where no citing store gives a scope. It matches a scope/name against the whole identity and a name against the name of every store. It matches the current identities first, then the former ones.

Source

pub fn store_name(&self, k: usize) -> Option<String>

store_name returns the shortest name of store k on the command line: its name, or its whole identity when another store shares that name. It returns None when the store has no identity.

Source

pub fn document_in( &self, citing: usize, store: Option<&str>, id: &str, ) -> Option<(usize, &Document)>

document_in finds the document that id refers to in store. store is a store prefix as a document of store citing wrote it. It returns the document with the index of the knowledge store that holds it. When store is None, it looks in citing.

Source

pub fn id_at(&self, path: &RepoPath) -> Option<(usize, String)>

id_at returns the id of the document or schema at path, in any store, with the index of its knowledge store.

Source

pub fn path_label( &self, citing: usize, path: &RepoPath, fragment: Option<&str>, ) -> Option<String>

path_label returns the canonical sokf: label that a document in store citing should use for a link to path with fragment (SOKF_FORMAT_65). The label depends on the file at path:

  • For a document, the label is its id with the fragment.
  • For a sidecar, the label is its id with the fragment, and with an empty fragment when the link has none, because the path refers to the sidecar file and not to the asset.
  • For an asset, the label is the id of its sidecar, which refers to the asset.

path_label returns None for any other file, and for an asset path with a fragment.

Source

pub fn prefix(&self, citing: usize, target: usize) -> Option<String>

prefix returns the store prefix that a document in store citing should put before an id in store target. It is the shortest unambiguous prefix (SOKF_FORMAT_65). The prefix is empty within one store, name: within one scope, and scope/name: otherwise. prefix returns None when the two stores differ and either has no identity.

Source

pub fn canonical_label( &self, citing: usize, target: usize, id: Option<&str>, fragment: Option<&str>, ) -> Option<String>

canonical_label returns the canonical sokf: label that a document in store citing should use for id and fragment in store target (SOKF_FORMAT_65).

Source

pub fn canonical_include( &self, citing: usize, target: usize, id: &str, fragment: Option<&str>, ) -> Option<String>

canonical_include returns the canonical target that an include marker in store citing should use for id and fragment in store target (SOKF_FORMAT_65).

Trait Implementations§

Source§

impl Debug for Model

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for Model

§

impl !RefUnwindSafe for Model

§

impl !Send for Model

§

impl !Sync for Model

§

impl !UnwindSafe for Model

§

impl Forget for Model

§

impl Move for Model

§

impl Unpin for Model

§

impl UnsafeUnpin for Model

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> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<'a, T> FromIn<'a, T> for T

Source§

fn from_in(t: T, _: &'a Allocator) -> T

Converts to this type from the input type within the given allocator.
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<'a, T, U> IntoIn<'a, U> for T
where U: FromIn<'a, T>,

Source§

fn into_in(self, allocator: &'a Allocator) -> U

Converts this type into the (usually inferred) input type within the given allocator.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.