pub struct KnowledgeBase { /* private fields */ }Expand description
The knowledge base separates raw storage from the parser-facing view:
commands/command_idx_by_name: raw explicit command store.characters/character_idx_by_name: raw character store.character_command_views: zero-arg Prefix commands projected from characters, so the parser can still recognize character control sequences as commands.active_command_idx_by_name: the single parser-facing index that tellslookup_command()whether the active entry for a name comes from an explicit command or a character-derived view.suppressed_command_names: names removed viaremove_item(Command). Prevents a deleted name from “reviving” through a character fallback.
Implementations§
Source§impl KnowledgeBase
impl KnowledgeBase
Sourcepub fn empty() -> Self
pub fn empty() -> Self
Return the active command for name, respecting suppression.
The active entry may be an explicit command or a character-derived
zero-arg view. Suppressed names always return None.
pub fn build_from_packages(packages: &[&str]) -> Self
pub fn try_build_from_packages( packages: &[&str], ) -> Result<Self, PackageLoadError>
pub fn try_build_from_packages_for_mode( packages: &[&str], target_mode: ContentMode, ) -> Result<Self, PackageLoadError>
pub fn lookup_command(&self, name: &str) -> Option<&ActiveCommandRecord>
Sourcepub fn lookup_explicit_command(
&self,
name: &str,
) -> Option<&ActiveCommandRecord>
pub fn lookup_explicit_command( &self, name: &str, ) -> Option<&ActiveCommandRecord>
Look up only the explicit (non-character-derived) command for name.
Sourcepub fn lookup_character(&self, name: &str) -> Option<&ActiveCharacterRecord>
pub fn lookup_character(&self, name: &str) -> Option<&ActiveCharacterRecord>
Look up raw character metadata by control-sequence name.
Sourcepub fn lookup_env(&self, name: &str) -> Option<&ActiveEnvironmentRecord>
pub fn lookup_env(&self, name: &str) -> Option<&ActiveEnvironmentRecord>
Look up environment metadata by name.
pub fn lookup_delimiter( &self, name: &str, is_control_sequence: bool, ) -> Option<&ActiveDelimiterRecord>
Sourcepub fn is_delimiter_control(&self, name: &str) -> bool
pub fn is_delimiter_control(&self, name: &str) -> bool
Check whether name is registered as a delimiter control sequence.
Sourcepub fn lookup_delimiter_control(&self, name: &str) -> Option<&'static str>
pub fn lookup_delimiter_control(&self, name: &str) -> Option<&'static str>
Look up a delimiter control, returning the interned &'static str name.
Sourcepub fn insert_item(
&mut self,
item: impl Into<ContextItem>,
) -> Result<(), ArgSpecParseError>
pub fn insert_item( &mut self, item: impl Into<ContextItem>, ) -> Result<(), ArgSpecParseError>
Insert a context item, dispatching to the appropriate typed inserter.
Sourcepub fn remove_item(&mut self, item: impl Into<ContextItem>) -> bool
pub fn remove_item(&mut self, item: impl Into<ContextItem>) -> bool
Remove a previously inserted item. Returns true if found.
pub fn insert_environment( &mut self, item: EnvironmentItem, ) -> Result<(), ArgSpecParseError>
pub fn insert_delimiter_control(&mut self, item: DelimiterControlItem)
Trait Implementations§
Source§impl Clone for KnowledgeBase
impl Clone for KnowledgeBase
Source§fn clone(&self) -> KnowledgeBase
fn clone(&self) -> KnowledgeBase
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for KnowledgeBase
impl RefUnwindSafe for KnowledgeBase
impl Send for KnowledgeBase
impl Sync for KnowledgeBase
impl Unpin for KnowledgeBase
impl UnsafeUnpin for KnowledgeBase
impl UnwindSafe for KnowledgeBase
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more