KnowledgeStore

Struct KnowledgeStore 

Source
pub struct KnowledgeStore { /* private fields */ }
Expand description

Knowledge store for managing knowledge items

Implementations§

Source§

impl KnowledgeStore

Source

pub fn new(base_dir: impl Into<PathBuf>) -> Self

Create a new knowledge store with the given base directory

Source

pub fn with_default_dir() -> Self

Create a store with default knowledge directory

Source

pub fn base_dir(&self) -> &Path

Get the base directory

Source

pub fn register(&self, item: KnowledgeItem)

Register a knowledge item

Source

pub fn load_user_items(&self) -> Result<usize, KnowledgeError>

Load user-persisted knowledge items from disk.

This is best-effort: invalid entries are skipped (with a warning) so the app can still start.

Source

pub fn upsert_user_item( &self, item: KnowledgeItem, ) -> Result<(), KnowledgeError>

Create or update a user knowledge item on disk, and register it in-memory.

Source

pub fn delete_user_item(&self, id: &str) -> Result<(), KnowledgeError>

Delete a user knowledge item from disk and remove it from the store.

Source

pub fn register_all(&self, items: impl IntoIterator<Item = KnowledgeItem>)

Register multiple knowledge items

Source

pub fn get(&self, id: &str) -> Option<KnowledgeItem>

Get a knowledge item by ID

Source

pub fn list(&self) -> Vec<KnowledgeItem>

List all knowledge items

Source

pub fn list_by_category(&self, category: &str) -> Vec<KnowledgeItem>

List knowledge items by category

Source

pub fn find(&self, query: &KnowledgeQuery) -> Vec<KnowledgeMatch>

Find knowledge items matching a query

Searches across all registered items regardless of their enabled field. Per-session enablement is managed by crate::KnowledgeSettingsManager.

Source

pub fn load_reference( &self, item_id: &str, ref_id: &str, ) -> Result<String, KnowledgeError>

Load a reference file content

Source

pub fn categories(&self) -> Vec<String>

Get all categories

Source

pub fn count(&self) -> usize

Count of knowledge items

Source

pub fn set_enabled(&self, id: &str, enabled: bool) -> Result<(), KnowledgeError>

Enable or disable a knowledge item

Source

pub fn clear_cache(&self)

Clear the reference cache

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more