#![allow(async_fn_in_trait)]
pub type Error = crate::Error;
#[derive(Clone, Debug, serde::Deserialize, Eq, PartialEq, serde::Serialize)]
#[serde(rename_all = "lowercase")]
pub enum Type {
Agent,
Workflow,
}
pub mod chat;
pub mod session;
pub trait Store: Send + Sync {
type Session: session::Store;
type Chat: chat::Store;
fn session(&self) -> &Self::Session;
fn chat(&self) -> &Self::Chat;
}
#[derive(Clone)]
pub struct Pair<S, C> {
session: std::sync::Arc<S>,
chat: std::sync::Arc<C>,
}
impl<S, C> Pair<S, C> {
pub fn new(session: S, chat: C) -> Self {
Self {
session: std::sync::Arc::new(session),
chat: std::sync::Arc::new(chat),
}
}
}
impl<S, C> Store for Pair<S, C>
where
S: session::Store,
C: chat::Store,
{
type Session = S;
type Chat = C;
fn session(&self) -> &Self::Session {
self.session.as_ref()
}
fn chat(&self) -> &Self::Chat {
self.chat.as_ref()
}
}