Skip to main content

Knowledge

Struct Knowledge 

Source
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: RepoPath

The root directory.

§manifest: Option<Manifest>

The manifest, when the manifest file exists.

§manifest_path: RepoPath

The 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

Source

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.

Source

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

ids returns the path of every document and schema that has id.

Source

pub fn documents_of(&self, type_name: &str) -> impl Iterator<Item = &Document>

documents_of returns the documents of type type_name.

Source

pub fn schemas_for(&self, type_name: &str) -> &[usize]

schemas_for returns the indexes of the schemas that dispatch on type_name.

Source

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

is_document reports whether path is a document of this knowledge store, schemas included.

Source

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

asset_of returns the asset that the document at sidecar describes, if there is one.

Source

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

asset_at returns the asset at path, if there is one.

Source

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).

Source

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

Source

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).

Source

pub fn identity(&self) -> Option<Identity>

identity returns the identity of the store, when its manifest declares a scope and a name that are both slugs.

Source

pub fn former(&self) -> Vec<Identity>

former returns the former identities of the store, which its manifest lists in renamed-from. It skips an entry that is not a valid identity.

Trait Implementations§

Source§

impl Debug for Knowledge

Source§

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

Formats the value using the given formatter. Read more

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> 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.