bamboo_domain/session/
persistence.rs1use std::io;
2use std::sync::Arc;
3
4use crate::session::types::Session;
5
6#[async_trait::async_trait]
13pub trait RuntimeSessionPersistence: Send + Sync {
14 async fn save_runtime_session(&self, session: &mut Session) -> io::Result<()>;
16
17 async fn append_token_usage_record(&self, session_id: &str, json_line: &str) -> io::Result<()> {
23 let _ = (session_id, json_line);
24 Ok(())
25 }
26}
27
28#[async_trait::async_trait]
29impl<T: RuntimeSessionPersistence + ?Sized> RuntimeSessionPersistence for Arc<T> {
30 async fn save_runtime_session(&self, session: &mut Session) -> io::Result<()> {
31 (**self).save_runtime_session(session).await
32 }
33
34 async fn append_token_usage_record(&self, session_id: &str, json_line: &str) -> io::Result<()> {
35 (**self)
36 .append_token_usage_record(session_id, json_line)
37 .await
38 }
39}