pub struct GateBuilder<User> { /* private fields */ }Expand description
Builds an immutable authorization gate registry.
Implementations§
Source§impl<User> GateBuilder<User>
impl<User> GateBuilder<User>
Sourcepub fn define<Context, Check, CheckFuture, Result>(
&mut self,
ability: impl Into<String>,
check: Check,
) -> &mut Self
pub fn define<Context, Check, CheckFuture, Result>( &mut self, ability: impl Into<String>, check: Check, ) -> &mut Self
Register an ability that requires an authenticated user.
Sourcepub fn define_for_guests<Context, Check, CheckFuture, Result>(
&mut self,
ability: impl Into<String>,
check: Check,
) -> &mut Self
pub fn define_for_guests<Context, Check, CheckFuture, Result>( &mut self, ability: impl Into<String>, check: Check, ) -> &mut Self
Register an ability that explicitly receives authenticated users or guests.
Sourcepub fn policy<P>(&mut self, policy: P) -> &mut Selfwhere
P: Policy<User>,
pub fn policy<P>(&mut self, policy: P) -> &mut Selfwhere
P: Policy<User>,
Register an application-owned policy.
Sourcepub fn before<Hook, HookFuture, Result>(&mut self, hook: Hook) -> &mut Self
pub fn before<Hook, HookFuture, Result>(&mut self, hook: Hook) -> &mut Self
Register a callback that can resolve an ability before its normal check.
Sourcepub fn after<Hook, HookFuture, Result>(&mut self, hook: Hook) -> &mut Self
pub fn after<Hook, HookFuture, Result>(&mut self, hook: Hook) -> &mut Self
Register a callback that observes every check and may resolve an otherwise missing ability.
Sourcepub fn default_denial(&mut self, response: AuthorizationResponse) -> &mut Self
pub fn default_denial(&mut self, response: AuthorizationResponse) -> &mut Self
Select the denial used when no ability or hook resolves a check.
Sourcepub fn events(&mut self, events: EventDispatcher) -> &mut Self
pub fn events(&mut self, events: EventDispatcher) -> &mut Self
Dispatch gate evaluation events through the application’s dispatcher.
Trait Implementations§
Auto Trait Implementations§
impl<User> !RefUnwindSafe for GateBuilder<User>
impl<User> !UnwindSafe for GateBuilder<User>
impl<User> Forget for GateBuilder<User>
impl<User> Freeze for GateBuilder<User>where
HashMap<AbilityKey, Arc<dyn Fn(Option<User>, &(dyn Any + 'static)) -> Result<Pin<Box<dyn Future<Output = AuthorizationResponse> + Send>>, GateError> + Sync + Send>>: Freeze,
Vec<Arc<dyn Fn(Option<User>, String) -> Pin<Box<dyn Future<Output = Option<AuthorizationResponse>> + Send>> + Sync + Send>>: Freeze,
Vec<Arc<dyn Fn(Option<User>, String, Option<AuthorizationResponse>) -> Pin<Box<dyn Future<Output = Option<AuthorizationResponse>> + Send>> + Sync + Send>>: Freeze,
impl<User> Move for GateBuilder<User>
impl<User> Send for GateBuilder<User>where
HashMap<AbilityKey, Arc<dyn Fn(Option<User>, &(dyn Any + 'static)) -> Result<Pin<Box<dyn Future<Output = AuthorizationResponse> + Send>>, GateError> + Sync + Send>>: Send,
Vec<Arc<dyn Fn(Option<User>, String) -> Pin<Box<dyn Future<Output = Option<AuthorizationResponse>> + Send>> + Sync + Send>>: Send,
Vec<Arc<dyn Fn(Option<User>, String, Option<AuthorizationResponse>) -> Pin<Box<dyn Future<Output = Option<AuthorizationResponse>> + Send>> + Sync + Send>>: Send,
impl<User> Sync for GateBuilder<User>where
HashMap<AbilityKey, Arc<dyn Fn(Option<User>, &(dyn Any + 'static)) -> Result<Pin<Box<dyn Future<Output = AuthorizationResponse> + Send>>, GateError> + Sync + Send>>: Sync,
Vec<Arc<dyn Fn(Option<User>, String) -> Pin<Box<dyn Future<Output = Option<AuthorizationResponse>> + Send>> + Sync + Send>>: Sync,
Vec<Arc<dyn Fn(Option<User>, String, Option<AuthorizationResponse>) -> Pin<Box<dyn Future<Output = Option<AuthorizationResponse>> + Send>> + Sync + Send>>: Sync,
impl<User> Unpin for GateBuilder<User>where
HashMap<AbilityKey, Arc<dyn Fn(Option<User>, &(dyn Any + 'static)) -> Result<Pin<Box<dyn Future<Output = AuthorizationResponse> + Send>>, GateError> + Sync + Send>>: Unpin,
Vec<Arc<dyn Fn(Option<User>, String) -> Pin<Box<dyn Future<Output = Option<AuthorizationResponse>> + Send>> + Sync + Send>>: Unpin,
Vec<Arc<dyn Fn(Option<User>, String, Option<AuthorizationResponse>) -> Pin<Box<dyn Future<Output = Option<AuthorizationResponse>> + Send>> + Sync + Send>>: Unpin,
impl<User> UnsafeUnpin for GateBuilder<User>where
HashMap<AbilityKey, Arc<dyn Fn(Option<User>, &(dyn Any + 'static)) -> Result<Pin<Box<dyn Future<Output = AuthorizationResponse> + Send>>, GateError> + Sync + Send>>: UnsafeUnpin,
Vec<Arc<dyn Fn(Option<User>, String) -> Pin<Box<dyn Future<Output = Option<AuthorizationResponse>> + Send>> + Sync + Send>>: UnsafeUnpin,
Vec<Arc<dyn Fn(Option<User>, String, Option<AuthorizationResponse>) -> Pin<Box<dyn Future<Output = Option<AuthorizationResponse>> + Send>> + Sync + Send>>: UnsafeUnpin,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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