pub struct KeyIndex {
pub document: HashMap<(RepoPath, String), Vec<KeyEntry>>,
pub knowledge: HashMap<(usize, String), Vec<KeyEntry>>,
pub repository: HashMap<String, Vec<KeyEntry>>,
pub anchors: BTreeMap<RepoPath, BTreeSet<String>>,
}Expand description
A KeyIndex holds the keys by the scope in which each key must be
unique (the grammar’s unique). It stores each key under its slug. The
slug is the id of the key’s anchor, and a fragment refers to a key by
that slug (SOKF_FORMAT_72).
Fields§
§document: HashMap<(RepoPath, String), Vec<KeyEntry>>Every key of every document, by path and by slug.
knowledge: HashMap<(usize, String), Vec<KeyEntry>>The keys of knowledge scope, by knowledge and by slug.
repository: HashMap<String, Vec<KeyEntry>>The keys of repository scope, by slug.
anchors: BTreeMap<RepoPath, BTreeSet<String>>The slugs of the anchors that the engine keeps for the units that
break their rules, by path. Such a unit captures no key, but a
fragment can name its anchor (SOKF_FORMAT_71).
Implementations§
Source§impl KeyIndex
impl KeyIndex
Sourcepub fn add(&mut self, entry: KeyEntry)
pub fn add(&mut self, entry: KeyEntry)
add records a captured key under its document and its scope. The
scope keeps one entry of each document for a key, the first that it
is given, because a bare reference resolves to the one document that captures
the key, however many units of the document capture it.
Sourcepub fn add_anchor(&mut self, path: RepoPath, slug: String)
pub fn add_anchor(&mut self, path: RepoPath, slug: String)
add_anchor records an anchor that the engine keeps in path for a
unit that breaks its rule.
Sourcepub fn anchors_of(&self, path: &RepoPath) -> impl Iterator<Item = &str>
pub fn anchors_of(&self, path: &RepoPath) -> impl Iterator<Item = &str>
anchors_of returns the slugs of the anchors that the engine keeps
in path.
Sourcepub fn of_document<'a>(
&'a self,
path: &'a RepoPath,
) -> impl Iterator<Item = &'a KeyEntry>
pub fn of_document<'a>( &'a self, path: &'a RepoPath, ) -> impl Iterator<Item = &'a KeyEntry>
of_document returns the keys that path captures.
Trait Implementations§
Source§impl Extend<KeyEntry> for KeyIndex
impl Extend<KeyEntry> for KeyIndex
Source§fn extend<I: IntoIterator<Item = KeyEntry>>(&mut self, entries: I)
fn extend<I: IntoIterator<Item = KeyEntry>>(&mut self, entries: I)
Source§fn extend_one(&mut self, item: T)
fn extend_one(&mut self, item: T)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)