use std::io;
use std::sync::Arc;
use crate::session::types::Session;
#[async_trait::async_trait]
pub trait RuntimeSessionPersistence: Send + Sync {
async fn save_runtime_session(&self, session: &mut Session) -> io::Result<()>;
async fn append_token_usage_record(&self, session_id: &str, json_line: &str) -> io::Result<()> {
let _ = (session_id, json_line);
Ok(())
}
}
#[async_trait::async_trait]
impl<T: RuntimeSessionPersistence + ?Sized> RuntimeSessionPersistence for Arc<T> {
async fn save_runtime_session(&self, session: &mut Session) -> io::Result<()> {
(**self).save_runtime_session(session).await
}
async fn append_token_usage_record(&self, session_id: &str, json_line: &str) -> io::Result<()> {
(**self)
.append_token_usage_record(session_id, json_line)
.await
}
}