pub struct Identity { /* private fields */ }Expand description
A verified identity bound to a session.
Created by the caller (typically a server or application layer) and
passed to GrafeoDB::session_with_identity.
The engine trusts the caller to construct the identity correctly.
Implementations§
Source§impl Identity
impl Identity
Sourcepub fn new(
user_id: impl Into<String>,
roles: impl IntoIterator<Item = Role>,
) -> Self
pub fn new( user_id: impl Into<String>, roles: impl IntoIterator<Item = Role>, ) -> Self
Creates a new identity with the given user ID and roles.
Sourcepub fn anonymous() -> Self
pub fn anonymous() -> Self
Creates an anonymous identity with full access.
Used internally when no identity is provided (backward-compatible
default). Anonymous sessions have the Role::Admin role.
Sourcepub fn with_grants(self, grants: impl IntoIterator<Item = Grant>) -> Self
pub fn with_grants(self, grants: impl IntoIterator<Item = Grant>) -> Self
Adds per-graph access grants to this identity.
When grants are set, the identity can only access the listed graphs at the specified role level. Graphs not in the grant list are inaccessible regardless of the identity’s top-level roles.
Sourcepub fn can_read(&self) -> bool
pub fn can_read(&self) -> bool
Returns true if this identity can perform read operations.
Any assigned role grants read access.
Sourcepub fn can_write(&self) -> bool
pub fn can_write(&self) -> bool
Returns true if this identity can perform write operations (create/update/delete nodes and edges, graph management).
Sourcepub fn can_admin(&self) -> bool
pub fn can_admin(&self) -> bool
Returns true if this identity can perform admin operations (schema DDL, index management, GC, configuration changes).
Sourcepub fn has_grants(&self) -> bool
pub fn has_grants(&self) -> bool
Returns true if this identity has per-graph restrictions.
Sourcepub fn can_access_graph(&self, graph: &str, required: Role) -> bool
pub fn can_access_graph(&self, graph: &str, required: Role) -> bool
Checks whether this identity can access the given graph at the required role level.
If no grants are configured, access is governed only by the identity’s top-level roles. If grants are configured, the graph must appear in the grant list with a sufficient role.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Identity
impl RefUnwindSafe for Identity
impl Send for Identity
impl Sync for Identity
impl Unpin for Identity
impl UnsafeUnpin for Identity
impl UnwindSafe for Identity
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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