pub struct ZanzibarStore { /* private fields */ }Expand description
In-memory Zanzibar-style relationship store with namespace configuration.
Implementations§
Source§impl ZanzibarStore
impl ZanzibarStore
Sourcepub fn new(max_depth: usize) -> Self
pub fn new(max_depth: usize) -> Self
Create a new Zanzibar store with the given max traversal depth.
Sourcepub async fn add_namespace(&self, config: NamespaceConfig)
pub async fn add_namespace(&self, config: NamespaceConfig)
Register a namespace configuration.
Sourcepub async fn write_tuple(&self, tuple: RelationTuple) -> Result<()>
pub async fn write_tuple(&self, tuple: RelationTuple) -> Result<()>
Write a relation tuple.
Sourcepub async fn delete_tuple(&self, tuple: &RelationTuple) -> bool
pub async fn delete_tuple(&self, tuple: &RelationTuple) -> bool
Delete a specific relation tuple.
Sourcepub async fn read_tuples(
&self,
object: &str,
relation: Option<&str>,
) -> Vec<RelationTuple>
pub async fn read_tuples( &self, object: &str, relation: Option<&str>, ) -> Vec<RelationTuple>
Read all tuples for an object, optionally filtered by relation.
Sourcepub async fn check(
&self,
object: &str,
relation: &str,
subject: &str,
) -> Result<bool>
pub async fn check( &self, object: &str, relation: &str, subject: &str, ) -> Result<bool>
Check — the core Zanzibar operation.
Determines whether subject has the relation on object by
traversing direct tuples, union rewrites, and tuple-to-userset paths.
Sourcepub async fn expand(&self, object: &str, relation: &str) -> Result<Vec<String>>
pub async fn expand(&self, object: &str, relation: &str) -> Result<Vec<String>>
Expand — list all subjects that have a given relation on an object.
Sourcepub async fn list_objects(
&self,
object_type: &str,
relation: &str,
subject: &str,
) -> Result<Vec<String>>
pub async fn list_objects( &self, object_type: &str, relation: &str, subject: &str, ) -> Result<Vec<String>>
List objects — find all objects of a given type where the subject has the specified relation (reverse lookup, uses BFS).
Sourcepub async fn tuple_count(&self) -> usize
pub async fn tuple_count(&self) -> usize
Get the count of stored tuples.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ZanzibarStore
impl !RefUnwindSafe for ZanzibarStore
impl Send for ZanzibarStore
impl Sync for ZanzibarStore
impl Unpin for ZanzibarStore
impl UnsafeUnpin for ZanzibarStore
impl !UnwindSafe for ZanzibarStore
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more