use crate::{
ContextId, ContextSnapshot, ContextWrite, ContextoidId, ContextoidRecord, IdReserve,
RelationRecord,
};
use alloc::vec::Vec;
pub trait ContextStorage {
type Error: core::fmt::Debug + core::fmt::Display;
type Slice;
fn reserve(&self, n: usize) -> impl Future<Output = Result<IdReserve, Self::Error>> + Send;
fn create_context(
&self,
name: &str,
) -> impl Future<Output = Result<ContextId, Self::Error>> + Send;
fn retract_context(
&self,
context: ContextId,
) -> impl Future<Output = Result<(), Self::Error>> + Send;
fn create_node(
&self,
nodes: &[ContextoidRecord],
) -> impl Future<Output = Result<(), Self::Error>> + Send;
fn retract_node(
&self,
node: ContextoidId,
) -> impl Future<Output = Result<(), Self::Error>> + Send;
fn create_edge(
&self,
edges: &[RelationRecord],
) -> impl Future<Output = Result<(), Self::Error>> + Send;
fn retract_edge(
&self,
from: ContextoidId,
to: ContextoidId,
) -> impl Future<Output = Result<(), Self::Error>> + Send;
fn link(
&self,
context: ContextId,
nodes: &[ContextoidId],
) -> impl Future<Output = Result<(), Self::Error>> + Send;
fn unlink(
&self,
context: ContextId,
nodes: &[ContextoidId],
) -> impl Future<Output = Result<(), Self::Error>> + Send;
fn attach(
&self,
context: ContextId,
extra: ContextId,
) -> impl Future<Output = Result<(), Self::Error>> + Send;
fn detach(
&self,
context: ContextId,
extra: ContextId,
) -> impl Future<Output = Result<(), Self::Error>> + Send;
fn commit(
&self,
writes: &[ContextWrite],
) -> impl Future<Output = Result<Vec<ContextId>, Self::Error>> + Send;
fn lookup(
&self,
ids: &[ContextoidId],
) -> impl Future<Output = Result<Vec<Option<ContextoidRecord>>, Self::Error>> + Send;
fn hydrate(
&self,
spec: &Self::Slice,
) -> impl Future<Output = Result<ContextSnapshot, Self::Error>> + Send;
}