Skip to main content

Db

Struct Db 

Source
pub struct Db { /* private fields */ }

Implementations§

Source§

impl Db

Source

pub fn create_message( &self, msg: &NewMessage<'_>, blocks: &[NewBlock<'_>], ) -> Result<Message, DbError>

Source

pub fn update_message_usage( &self, message_id: &str, tokens_in: i64, tokens_out: i64, latency_ms: i64, ) -> Result<(), DbError>

Source

pub fn get_session_messages( &self, session_id: &str, ) -> Result<Vec<Message>, DbError>

Source

pub fn delete_message(&self, message_id: &str) -> Result<(), DbError>

Delete a message and its blocks by ID.

Source

pub fn compress_thinking_blocks( &self, older_than_days: i64, ) -> Result<usize, DbError>

Source§

impl Db

Source§

impl Db

Source

pub fn create_session(&self, title: &str) -> Result<Session, DbError>

Source

pub fn get_session(&self, id: &str) -> Result<Session, DbError>

Source

pub fn list_sessions(&self) -> Result<Vec<Session>, DbError>

Source

pub fn update_session_title(&self, id: &str, title: &str) -> Result<(), DbError>

Source

pub fn update_session_metadata( &self, id: &str, metadata: &str, ) -> Result<(), DbError>

Source

pub fn list_sessions_with_preview( &self, ) -> Result<Vec<(Session, Option<String>)>, DbError>

Get all sessions with their last message preview in a single query. Avoids N+1 queries when loading the sidebar.

Source

pub fn delete_session(&self, id: &str) -> Result<(), DbError>

Source

pub fn add_session_tag( &self, session_id: &str, tag: &str, ) -> Result<(), DbError>

Source

pub fn remove_session_tag( &self, session_id: &str, tag: &str, ) -> Result<(), DbError>

Source§

impl Db

Source

pub fn open(path: &str) -> Result<Self, DbError>

Source

pub fn open_in_memory() -> Result<Self, DbError>

Source

pub fn conn(&self) -> &Connection

Auto Trait Implementations§

§

impl !Freeze for Db

§

impl !RefUnwindSafe for Db

§

impl Send for Db

§

impl !Sync for Db

§

impl Unpin for Db

§

impl UnsafeUnpin for Db

§

impl !UnwindSafe for Db

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.

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.