pub struct ChatDatabase {
pub conn: Connection,
}Expand description
Universal Chat Database manager
Fields§
§conn: ConnectionImplementations§
Source§impl ChatDatabase
impl ChatDatabase
Sourcepub fn open_in_memory() -> Result<Self>
pub fn open_in_memory() -> Result<Self>
Open an in-memory database (for testing)
Sourcepub fn connection(&self) -> &Connection
pub fn connection(&self) -> &Connection
Get access to the underlying connection
Sourcepub fn get_version(&self) -> Result<String>
pub fn get_version(&self) -> Result<String>
Get schema version
Sourcepub fn upsert_workspace(&self, workspace: &Workspace) -> Result<()>
pub fn upsert_workspace(&self, workspace: &Workspace) -> Result<()>
Insert or update a workspace
Sourcepub fn list_workspaces(&self) -> Result<Vec<Workspace>>
pub fn list_workspaces(&self) -> Result<Vec<Workspace>>
List all workspaces
Sourcepub fn upsert_session(&self, session: &Session) -> Result<bool>
pub fn upsert_session(&self, session: &Session) -> Result<bool>
Insert or update a session
Sourcepub fn list_sessions(
&self,
workspace_id: Option<&str>,
provider: Option<&str>,
limit: usize,
) -> Result<Vec<Session>>
pub fn list_sessions( &self, workspace_id: Option<&str>, provider: Option<&str>, limit: usize, ) -> Result<Vec<Session>>
List sessions with optional filters
Sourcepub fn count_sessions_by_provider(&self) -> Result<Vec<(String, i64)>>
pub fn count_sessions_by_provider(&self) -> Result<Vec<(String, i64)>>
Count sessions by provider
Sourcepub fn insert_message(&self, message: &Message) -> Result<()>
pub fn insert_message(&self, message: &Message) -> Result<()>
Insert a message
Sourcepub fn get_messages(&self, session_id: &str) -> Result<Vec<Message>>
pub fn get_messages(&self, session_id: &str) -> Result<Vec<Message>>
Get messages for a session
Sourcepub fn create_checkpoint(
&self,
session_id: &str,
name: &str,
description: Option<&str>,
git_commit: Option<&str>,
) -> Result<Checkpoint>
pub fn create_checkpoint( &self, session_id: &str, name: &str, description: Option<&str>, git_commit: Option<&str>, ) -> Result<Checkpoint>
Create a checkpoint for a session
Sourcepub fn list_checkpoints(&self, session_id: &str) -> Result<Vec<Checkpoint>>
pub fn list_checkpoints(&self, session_id: &str) -> Result<Vec<Checkpoint>>
List checkpoints for a session
Add a share link
Get share link by URL
List all share links
Mark a share link as imported
Sourcepub fn get_statistics(&self) -> Result<DatabaseStats>
pub fn get_statistics(&self) -> Result<DatabaseStats>
Get database statistics
Auto Trait Implementations§
impl !Freeze for ChatDatabase
impl !RefUnwindSafe for ChatDatabase
impl Send for ChatDatabase
impl !Sync for ChatDatabase
impl Unpin for ChatDatabase
impl !UnwindSafe for ChatDatabase
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
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>
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