pub struct Database { /* private fields */ }Implementations§
Source§impl Database
impl Database
pub fn new() -> Result<Self>
pub fn save_chat_entry_with_tokens( &self, chat_id: &str, model: &str, question: &str, response: &str, input_tokens: Option<i32>, output_tokens: Option<i32>, ) -> Result<()>
pub fn get_chat_history(&self, chat_id: &str) -> Result<Vec<ChatEntry>>
pub fn get_all_logs(&self) -> Result<Vec<ChatEntry>>
pub fn get_recent_logs(&self, limit: Option<usize>) -> Result<Vec<ChatEntry>>
pub fn set_current_session_id(&self, session_id: &str) -> Result<()>
pub fn get_current_session_id(&self) -> Result<Option<String>>
pub fn purge_all_logs(&self) -> Result<()>
Sourcepub fn purge_logs_by_age(&self, days: u32) -> Result<usize>
pub fn purge_logs_by_age(&self, days: u32) -> Result<usize>
Purge logs based on age (older than specified days)
Sourcepub fn purge_logs_keep_recent(&self, keep_count: usize) -> Result<usize>
pub fn purge_logs_keep_recent(&self, keep_count: usize) -> Result<usize>
Purge logs to keep only the most recent N entries
Sourcepub fn purge_logs_by_size(&self, max_size_mb: u64) -> Result<usize>
pub fn purge_logs_by_size(&self, max_size_mb: u64) -> Result<usize>
Purge logs when database size exceeds threshold (in MB)
Sourcepub fn smart_purge(
&self,
max_age_days: Option<u32>,
max_entries: Option<usize>,
max_size_mb: Option<u64>,
) -> Result<usize>
pub fn smart_purge( &self, max_age_days: Option<u32>, max_entries: Option<usize>, max_size_mb: Option<u64>, ) -> Result<usize>
Smart purge with configurable thresholds
pub fn clear_session(&self, session_id: &str) -> Result<()>
pub fn get_stats(&self) -> Result<DatabaseStats>
Auto Trait Implementations§
impl Freeze for Database
impl RefUnwindSafe for Database
impl Send for Database
impl Sync for Database
impl Unpin for Database
impl UnwindSafe for Database
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 moreCreates a shared type from an unshared type.