use super::types::{
CheckResult, Consistency, NamespaceSchema, ObjectRef, SubjectRef, Tuple, UsersetTree,
};
#[async_trait::async_trait]
pub trait ZanzibarStore: Send + Sync + 'static {
async fn define_namespace(&self, schema: &NamespaceSchema) -> anyhow::Result<()>;
async fn get_namespace(&self, name: &str) -> anyhow::Result<Option<NamespaceSchema>>;
async fn list_namespaces(&self) -> anyhow::Result<Vec<NamespaceSchema>>;
async fn write_tuple(&self, tuple: &Tuple) -> anyhow::Result<()>;
async fn write_tuples(&self, tuples: &[Tuple]) -> anyhow::Result<()>;
async fn delete_tuple(&self, tuple: &Tuple) -> anyhow::Result<bool>;
async fn check(
&self,
resource: &ObjectRef,
permission: &str,
subject: &SubjectRef,
consistency: Consistency,
) -> anyhow::Result<CheckResult>;
async fn expand(
&self,
resource: &ObjectRef,
relation: &str,
depth_limit: u32,
) -> anyhow::Result<UsersetTree>;
async fn lookup_resources(
&self,
resource_type: &str,
permission: &str,
subject: &SubjectRef,
) -> anyhow::Result<Vec<ObjectRef>>;
async fn lookup_subjects(
&self,
subject_type: &str,
resource: &ObjectRef,
permission: &str,
) -> anyhow::Result<Vec<SubjectRef>>;
}