pub struct KnowledgeStore { /* private fields */ }Expand description
A validated local knowledge store backed by one JSON snapshot file.
Implementations§
Source§impl KnowledgeStore
impl KnowledgeStore
Sourcepub fn open(path: impl Into<PathBuf>) -> Result<Self, KnowledgeStoreError>
pub fn open(path: impl Into<PathBuf>) -> Result<Self, KnowledgeStoreError>
Open an existing store or an empty store at path.
Sourcepub fn open_with_limits(
path: impl Into<PathBuf>,
limits: KnowledgeStoreLimits,
) -> Result<Self, KnowledgeStoreError>
pub fn open_with_limits( path: impl Into<PathBuf>, limits: KnowledgeStoreLimits, ) -> Result<Self, KnowledgeStoreError>
Open a store with explicit record and serialized-byte limits.
Sourcepub fn limits(&self) -> KnowledgeStoreLimits
pub fn limits(&self) -> KnowledgeStoreLimits
Return the active store limits.
Sourcepub fn snapshot(&self) -> &KnowledgeStoreSnapshot
pub fn snapshot(&self) -> &KnowledgeStoreSnapshot
Return the last validated in-memory snapshot.
Sourcepub fn refresh(&mut self) -> Result<(), KnowledgeStoreError>
pub fn refresh(&mut self) -> Result<(), KnowledgeStoreError>
Re-read the snapshot under the store lock.
Sourcepub fn get(&self, record_id: &str) -> Option<&KnowledgeRecord>
pub fn get(&self, record_id: &str) -> Option<&KnowledgeRecord>
Find one record by its stable ID.
Sourcepub fn assess(
&self,
context: &KnowledgeLookupContext,
) -> Vec<KnowledgeAssessment>
pub fn assess( &self, context: &KnowledgeLookupContext, ) -> Vec<KnowledgeAssessment>
Assess all records against fresh session dimensions without changing the store or returning any executable browser reference.
Sourcepub fn records(&self) -> &[KnowledgeRecord]
pub fn records(&self) -> &[KnowledgeRecord]
Return the validated records for inspection or export.
Sourcepub fn stats(&self) -> Result<KnowledgeStoreStats, KnowledgeStoreError>
pub fn stats(&self) -> Result<KnowledgeStoreStats, KnowledgeStoreError>
Return bounded serialized-size and lifecycle counts.
Sourcepub fn replace_snapshot(
&mut self,
snapshot: KnowledgeStoreSnapshot,
) -> Result<(), KnowledgeStoreError>
pub fn replace_snapshot( &mut self, snapshot: KnowledgeStoreSnapshot, ) -> Result<(), KnowledgeStoreError>
Replace the complete store only after validating its schema and bounds.
Sourcepub fn transition(
&mut self,
record_id: &str,
next: KnowledgeConfidence,
reason: String,
observed_at: String,
fresh_verification: bool,
) -> Result<KnowledgeStoreChange, KnowledgeStoreError>
pub fn transition( &mut self, record_id: &str, next: KnowledgeConfidence, reason: String, observed_at: String, fresh_verification: bool, ) -> Result<KnowledgeStoreChange, KnowledgeStoreError>
Transition one record and retain the lifecycle evidence in its history.
Sourcepub fn purge_origin(
&mut self,
origin: &str,
) -> Result<KnowledgePurgeResult, KnowledgeStoreError>
pub fn purge_origin( &mut self, origin: &str, ) -> Result<KnowledgePurgeResult, KnowledgeStoreError>
Remove every record scoped to one exact origin.
Sourcepub fn upsert(
&mut self,
record: KnowledgeRecord,
) -> Result<KnowledgeStoreChange, KnowledgeStoreError>
pub fn upsert( &mut self, record: KnowledgeRecord, ) -> Result<KnowledgeStoreChange, KnowledgeStoreError>
Insert or replace a record, then prune the least useful records first.
Sourcepub fn remove(
&mut self,
record_id: &str,
) -> Result<KnowledgeStoreChange, KnowledgeStoreError>
pub fn remove( &mut self, record_id: &str, ) -> Result<KnowledgeStoreChange, KnowledgeStoreError>
Remove one record and persist the resulting snapshot.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for KnowledgeStore
impl RefUnwindSafe for KnowledgeStore
impl Send for KnowledgeStore
impl Sync for KnowledgeStore
impl Unpin for KnowledgeStore
impl UnsafeUnpin 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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