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(
23 &self,
24 session_id: &str,
25 json_line: &str,
26 ) -> io::Result<()> {
27 let _ = (session_id, json_line);
28 Ok(())
29 }
30}
31
32#[async_trait::async_trait]
33impl<T: RuntimeSessionPersistence + ?Sized> RuntimeSessionPersistence for Arc<T> {
34 async fn save_runtime_session(&self, session: &mut Session) -> io::Result<()> {
35 (**self).save_runtime_session(session).await
36 }
37
38 async fn append_token_usage_record(
39 &self,
40 session_id: &str,
41 json_line: &str,
42 ) -> io::Result<()> {
43 (**self)
44 .append_token_usage_record(session_id, json_line)
45 .await
46 }
47}