pub struct KnowledgeStore { /* private fields */ }Expand description
Knowledge store for managing knowledge items
Implementations§
Source§impl KnowledgeStore
impl KnowledgeStore
Sourcepub fn new(base_dir: impl Into<PathBuf>) -> KnowledgeStore
pub fn new(base_dir: impl Into<PathBuf>) -> KnowledgeStore
Create a new knowledge store with the given base directory
Sourcepub fn with_default_dir() -> KnowledgeStore
pub fn with_default_dir() -> KnowledgeStore
Create a store with default knowledge directory
Sourcepub fn register(&self, item: KnowledgeItem)
pub fn register(&self, item: KnowledgeItem)
Register a knowledge item
Sourcepub fn load_user_items(&self) -> Result<usize, KnowledgeError>
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.
Sourcepub fn upsert_user_item(
&self,
item: KnowledgeItem,
) -> Result<(), KnowledgeError>
pub fn upsert_user_item( &self, item: KnowledgeItem, ) -> Result<(), KnowledgeError>
Create or update a user knowledge item on disk, and register it in-memory.
Sourcepub fn delete_user_item(&self, id: &str) -> Result<(), KnowledgeError>
pub fn delete_user_item(&self, id: &str) -> Result<(), KnowledgeError>
Delete a user knowledge item from disk and remove it from the store.
Sourcepub fn register_all(&self, items: impl IntoIterator<Item = KnowledgeItem>)
pub fn register_all(&self, items: impl IntoIterator<Item = KnowledgeItem>)
Register multiple knowledge items
Sourcepub fn get(&self, id: &str) -> Option<KnowledgeItem>
pub fn get(&self, id: &str) -> Option<KnowledgeItem>
Get a knowledge item by ID
Sourcepub fn list(&self) -> Vec<KnowledgeItem>
pub fn list(&self) -> Vec<KnowledgeItem>
List all knowledge items
Sourcepub fn list_by_category(&self, category: &str) -> Vec<KnowledgeItem>
pub fn list_by_category(&self, category: &str) -> Vec<KnowledgeItem>
List knowledge items by category
Sourcepub fn find(&self, query: &KnowledgeQuery) -> Vec<KnowledgeMatch>
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.
Sourcepub fn load_reference(
&self,
item_id: &str,
ref_id: &str,
) -> Result<String, KnowledgeError>
pub fn load_reference( &self, item_id: &str, ref_id: &str, ) -> Result<String, KnowledgeError>
Load a reference file content
Sourcepub fn categories(&self) -> Vec<String>
pub fn categories(&self) -> Vec<String>
Get all categories
Sourcepub fn set_enabled(&self, id: &str, enabled: bool) -> Result<(), KnowledgeError>
pub fn set_enabled(&self, id: &str, enabled: bool) -> Result<(), KnowledgeError>
Enable or disable a knowledge item
Sourcepub fn clear_cache(&self)
pub fn clear_cache(&self)
Clear the reference cache
Auto Trait Implementations§
impl !Freeze for KnowledgeStore
impl RefUnwindSafe for KnowledgeStore
impl Send for KnowledgeStore
impl Sync for KnowledgeStore
impl Unpin for KnowledgeStore
impl UnwindSafe for KnowledgeStore
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].