pub struct PrivateStore<B: StorageBackend> { /* private fields */ }Expand description
Encrypted per-session history store.
Generic over StorageBackend so the same code works with FsBackend
(native/WASM) and MemoryBackend (tests).
Implementations§
Source§impl<B: StorageBackend> PrivateStore<B>
impl<B: StorageBackend> PrivateStore<B>
pub fn new(backend: B, key: StorageKey) -> Self
Sourcepub fn save<T: Serialize>(&self, session_id: &Uuid, entries: &[T]) -> Result<()>
pub fn save<T: Serialize>(&self, session_id: &Uuid, entries: &[T]) -> Result<()>
Encrypt entries and atomically write to storage.
A fresh 12-byte nonce is generated from OsRng on every call.
Sourcepub fn delete(&self, session_id: &Uuid) -> Result<()>
pub fn delete(&self, session_id: &Uuid) -> Result<()>
Delete the encrypted history file for session_id.
Sourcepub fn load<T: for<'de> Deserialize<'de>>(
&self,
session_id: &Uuid,
) -> Result<Option<Vec<T>>>
pub fn load<T: for<'de> Deserialize<'de>>( &self, session_id: &Uuid, ) -> Result<Option<Vec<T>>>
Load and decrypt entries for session_id.
Returns None if no history file exists yet.
Sourcepub fn list_conversations(&self, model_ref: &str) -> Vec<ConversationMeta>
pub fn list_conversations(&self, model_ref: &str) -> Vec<ConversationMeta>
List all conversations for a given model.
Sourcepub fn list_all_conversations(&self) -> Vec<ConversationMeta>
pub fn list_all_conversations(&self) -> Vec<ConversationMeta>
List all conversations across all models.
Sourcepub fn register_conversation(&self, meta: ConversationMeta) -> Result<()>
pub fn register_conversation(&self, meta: ConversationMeta) -> Result<()>
Register a new conversation in the manifest.
Sourcepub fn update_last_active(&self, uuid: &Uuid) -> Result<()>
pub fn update_last_active(&self, uuid: &Uuid) -> Result<()>
Update the last_active timestamp for a conversation.
Sourcepub fn delete_conversation(&self, uuid: &Uuid) -> Result<()>
pub fn delete_conversation(&self, uuid: &Uuid) -> Result<()>
Delete a conversation: removes both the history file and the manifest entry.
Auto Trait Implementations§
impl<B> Freeze for PrivateStore<B>where
B: Freeze,
impl<B> RefUnwindSafe for PrivateStore<B>where
B: RefUnwindSafe,
impl<B> Send for PrivateStore<B>
impl<B> Sync for PrivateStore<B>
impl<B> Unpin for PrivateStore<B>where
B: Unpin,
impl<B> UnsafeUnpin for PrivateStore<B>where
B: UnsafeUnpin,
impl<B> UnwindSafe for PrivateStore<B>where
B: UnwindSafe,
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
§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>
Converts
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>
Converts
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> JaggedSlice<T> for T
impl<T> JaggedSlice<T> for T
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ServiceExt for T
impl<T> ServiceExt for T
§fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
Apply a transformation to the response body. Read more
§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using HTTP status codes. Read more
§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using gRPC headers. Read more