pub struct Knowledge {Show 13 fields
pub root: RepoPath,
pub manifest: Option<Manifest>,
pub manifest_path: RepoPath,
pub schemas: Vec<SchemaDocument>,
pub documents: Vec<Document>,
pub indexes: Vec<IndexFile>,
pub assets: Vec<Asset>,
pub by_id: HashMap<String, Vec<usize>>,
pub by_path: HashMap<RepoPath, usize>,
pub by_type: HashMap<String, Vec<usize>>,
pub schemas_by_type: HashMap<String, Vec<usize>>,
pub asset_by_path: HashMap<RepoPath, usize>,
pub asset_of_sidecar: HashMap<RepoPath, usize>,
}Expand description
A Knowledge is one knowledge store.
Fields§
§root: RepoPathThe root directory.
manifest: Option<Manifest>The manifest, when the manifest file exists.
manifest_path: RepoPathThe path of the manifest.
schemas: Vec<SchemaDocument>The schemas, by path.
documents: Vec<Document>The documents, by path.
indexes: Vec<IndexFile>The index files, by path.
assets: Vec<Asset>The assets, by path (FORMAT-1_AC-1).
by_id: HashMap<String, Vec<usize>>The documents, by id. An id that more than one document has is a
duplicate.
by_path: HashMap<RepoPath, usize>The documents, by path.
by_type: HashMap<String, Vec<usize>>The documents, by type.
schemas_by_type: HashMap<String, Vec<usize>>The schemas, by the type that each one dispatches on.
asset_by_path: HashMap<RepoPath, usize>The assets, by path.
asset_of_sidecar: HashMap<RepoPath, usize>The assets, by the path of their sidecar.
Implementations§
Source§impl Knowledge
impl Knowledge
Sourcepub fn document(&self, id: &str) -> Option<&Document>
pub fn document(&self, id: &str) -> Option<&Document>
document returns the document with id, when exactly one document
has it. A schema is a document of type Schema, so document
resolves the id of a schema too.
Sourcepub fn ids(&self, id: &str) -> Vec<&RepoPath>
pub fn ids(&self, id: &str) -> Vec<&RepoPath>
ids returns the path of every document and schema that has id.
Sourcepub fn documents_of(&self, type_name: &str) -> impl Iterator<Item = &Document>
pub fn documents_of(&self, type_name: &str) -> impl Iterator<Item = &Document>
documents_of returns the documents of type type_name.
Sourcepub fn schemas_for(&self, type_name: &str) -> &[usize]
pub fn schemas_for(&self, type_name: &str) -> &[usize]
schemas_for returns the indexes of the schemas that dispatch on
type_name.
Sourcepub fn is_document(&self, path: &RepoPath) -> bool
pub fn is_document(&self, path: &RepoPath) -> bool
is_document reports whether path is a document of this knowledge
store, schemas included.
Sourcepub fn asset_of(&self, sidecar: &RepoPath) -> Option<&Asset>
pub fn asset_of(&self, sidecar: &RepoPath) -> Option<&Asset>
asset_of returns the asset that the document at sidecar
describes, if there is one.
Sourcepub fn asset_at(&self, path: &RepoPath) -> Option<&Asset>
pub fn asset_at(&self, path: &RepoPath) -> Option<&Asset>
asset_at returns the asset at path, if there is one.
Sourcepub fn schema_key(&self, i: usize) -> String
pub fn schema_key(&self, i: usize) -> String
schema_key returns the key of schema i. The key is the value of
the schema’s type const. A schema that has no such const
dispatches only by its globs, and its key is its path (CACHE-1_AC-15).
Sourcepub fn schema_by_id(&self, id: &str) -> Option<usize>
pub fn schema_by_id(&self, id: &str) -> Option<usize>
schema_by_id returns the index of the schema with id, when exactly
one schema has it.
Source§impl Knowledge
impl Knowledge
Sourcepub fn capped(&self) -> bool
pub fn capped(&self) -> bool
capped returns whether the store’s manifest caps the scope of its
keys at the store, with unique: knowledge (SOKF_FORMAT_208).