use std::future::Future;
use std::pin::Pin;
use crate::error::Result;
use crate::trie::accumulator::AccumulatorState;
use crate::trie::serialization::TrieEnvelope;
use crate::types::plan::ExecutionPlan;
use crate::types::records::RunRecord;
type BoxStorageFuture<'a, T> = Pin<Box<dyn Future<Output = Result<T>> + Send + 'a>>;
type PromptIrList = Vec<crate::acg::prompt_ir::PromptIR>;
type StabilityResult = crate::acg::stability::StabilityAnalysisResult;
pub trait StorageBackend: Send + Sync + 'static {
fn store_run(&self, record: &RunRecord) -> impl Future<Output = Result<()>> + Send;
fn load_plan(
&self,
agent_id: &str,
) -> impl Future<Output = Result<Option<ExecutionPlan>>> + Send;
fn list_runs(&self, agent_id: &str) -> impl Future<Output = Result<Vec<RunRecord>>> + Send;
}
pub trait StorageBackendDyn: Send + Sync + 'static {
fn store_run_dyn<'a>(&'a self, record: &'a RunRecord) -> BoxStorageFuture<'a, ()>;
fn load_plan_dyn<'a>(
&'a self,
agent_id: &'a str,
) -> BoxStorageFuture<'a, Option<ExecutionPlan>>;
fn list_runs_dyn<'a>(&'a self, agent_id: &'a str) -> BoxStorageFuture<'a, Vec<RunRecord>>;
fn store_trie<'a>(
&'a self,
agent_id: &'a str,
envelope: &'a TrieEnvelope,
) -> BoxStorageFuture<'a, ()>;
fn load_trie<'a>(&'a self, agent_id: &'a str) -> BoxStorageFuture<'a, Option<TrieEnvelope>>;
fn store_accumulators<'a>(
&'a self,
agent_id: &'a str,
state: &'a AccumulatorState,
) -> BoxStorageFuture<'a, ()>;
fn load_accumulators<'a>(
&'a self,
agent_id: &'a str,
) -> BoxStorageFuture<'a, Option<AccumulatorState>>;
fn store_plan(&self, _plan: &ExecutionPlan) -> Result<()> {
Ok(())
}
fn store_observations<'a>(
&'a self,
_agent_id: &'a str,
_observations: &'a [crate::acg::prompt_ir::PromptIR],
) -> BoxStorageFuture<'a, ()> {
Box::pin(async move { Ok(()) })
}
fn load_observations<'a>(
&'a self,
_agent_id: &'a str,
) -> BoxStorageFuture<'a, Option<PromptIrList>> {
Box::pin(async move { Ok(None) })
}
fn store_stability<'a>(
&'a self,
_agent_id: &'a str,
_result: &'a StabilityResult,
) -> BoxStorageFuture<'a, ()> {
Box::pin(async move { Ok(()) })
}
fn load_stability<'a>(
&'a self,
_agent_id: &'a str,
) -> BoxStorageFuture<'a, Option<StabilityResult>> {
Box::pin(async move { Ok(None) })
}
}