pub struct ServicePermissionGuard<E, S, P>{ /* private fields */ }Expand description
Generic permission guard that wraps both a service and an auth context provider.
Generated modules emit a type alias:
ⓘ
// Generated (Phase 1):
impl ResourcePolicy<Order> for OrderPolicy {
fn resource_type() -> &'static str { "orders" }
fn create_permission() -> &'static str { "orders:create" }
// ...
async fn can(&self, action, entity, ctx) -> bool { ... }
}
pub type OrderGuard = ServicePermissionGuard<Order, OrderService, OrderPolicy>;E — entity type
S — underlying service
P — resource policy implementation
Implementations§
Source§impl<E, S, P> ServicePermissionGuard<E, S, P>
impl<E, S, P> ServicePermissionGuard<E, S, P>
pub fn new(service: Arc<S>, policy: Arc<P>) -> Self
Sourcepub async fn check(
&self,
action: ResourceAction,
entity: &E,
ctx: &AuthContext,
) -> Result<(), AccessDenied>
pub async fn check( &self, action: ResourceAction, entity: &E, ctx: &AuthContext, ) -> Result<(), AccessDenied>
Check whether ctx may perform action on entity, returning
Ok(()) on permit or Err(AccessDenied) on deny.
Auto Trait Implementations§
impl<E, S, P> Freeze for ServicePermissionGuard<E, S, P>
impl<E, S, P> RefUnwindSafe for ServicePermissionGuard<E, S, P>
impl<E, S, P> Send for ServicePermissionGuard<E, S, P>
impl<E, S, P> Sync for ServicePermissionGuard<E, S, P>
impl<E, S, P> Unpin for ServicePermissionGuard<E, S, P>
impl<E, S, P> UnsafeUnpin for ServicePermissionGuard<E, S, P>
impl<E, S, P> UnwindSafe for ServicePermissionGuard<E, S, P>
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
Mutably borrows from an owned value. Read more