pub struct UserGate<User> { /* private fields */ }Expand description
A request-oriented view of a gate registry for one user or guest.
Implementations§
Source§impl<User> UserGate<User>
impl<User> UserGate<User>
Sourcepub async fn inspect<Context>(
&self,
ability: impl AsRef<str>,
context: &Context,
) -> Result<AuthorizationResponse, GateError>
pub async fn inspect<Context>( &self, ability: impl AsRef<str>, context: &Context, ) -> Result<AuthorizationResponse, GateError>
Inspect an ability’s complete response.
Sourcepub async fn allows<Context>(
&self,
ability: impl AsRef<str>,
context: &Context,
) -> Result<bool, GateError>
pub async fn allows<Context>( &self, ability: impl AsRef<str>, context: &Context, ) -> Result<bool, GateError>
Determine whether an ability is allowed.
Sourcepub async fn denies<Context>(
&self,
ability: impl AsRef<str>,
context: &Context,
) -> Result<bool, GateError>
pub async fn denies<Context>( &self, ability: impl AsRef<str>, context: &Context, ) -> Result<bool, GateError>
Determine whether an ability is denied.
Authorize an ability or return its denial.
Sourcepub async fn check<Ability, Abilities, Context>(
&self,
abilities: Abilities,
context: &Context,
) -> Result<bool, GateError>
pub async fn check<Ability, Abilities, Context>( &self, abilities: Abilities, context: &Context, ) -> Result<bool, GateError>
Determine whether every ability is allowed for the same context.
Sourcepub async fn any<Ability, Abilities, Context>(
&self,
abilities: Abilities,
context: &Context,
) -> Result<bool, GateError>
pub async fn any<Ability, Abilities, Context>( &self, abilities: Abilities, context: &Context, ) -> Result<bool, GateError>
Determine whether any ability is allowed for the same context.
Sourcepub async fn none<Ability, Abilities, Context>(
&self,
abilities: Abilities,
context: &Context,
) -> Result<bool, GateError>
pub async fn none<Ability, Abilities, Context>( &self, abilities: Abilities, context: &Context, ) -> Result<bool, GateError>
Determine whether no ability is allowed for the same context.
Sourcepub fn allow_if<Outcome>(
&self,
condition: Outcome,
) -> Result<AuthorizationResponse, AuthorizationError>where
Outcome: IntoAuthorizationResponse,
pub fn allow_if<Outcome>(
&self,
condition: Outcome,
) -> Result<AuthorizationResponse, AuthorizationError>where
Outcome: IntoAuthorizationResponse,
Perform an inline allow check without running registered hooks.
Sourcepub fn allow_if_with_user<Outcome>(
&self,
check: impl FnOnce(&User) -> Outcome,
) -> Result<AuthorizationResponse, AuthorizationError>where
Outcome: IntoAuthorizationResponse,
pub fn allow_if_with_user<Outcome>(
&self,
check: impl FnOnce(&User) -> Outcome,
) -> Result<AuthorizationResponse, AuthorizationError>where
Outcome: IntoAuthorizationResponse,
Perform an authenticated-user inline allow check without registered hooks.
Sourcepub fn allow_if_for_guests<Outcome>(
&self,
check: impl FnOnce(Option<&User>) -> Outcome,
) -> Result<AuthorizationResponse, AuthorizationError>where
Outcome: IntoAuthorizationResponse,
pub fn allow_if_for_guests<Outcome>(
&self,
check: impl FnOnce(Option<&User>) -> Outcome,
) -> Result<AuthorizationResponse, AuthorizationError>where
Outcome: IntoAuthorizationResponse,
Perform a guest-aware inline allow check without registered hooks.
Sourcepub fn deny_if<Outcome>(
&self,
condition: Outcome,
) -> Result<AuthorizationResponse, AuthorizationError>where
Outcome: IntoAuthorizationResponse,
pub fn deny_if<Outcome>(
&self,
condition: Outcome,
) -> Result<AuthorizationResponse, AuthorizationError>where
Outcome: IntoAuthorizationResponse,
Perform an inline deny check without running registered hooks.
Sourcepub fn deny_if_with_user<Outcome>(
&self,
check: impl FnOnce(&User) -> Outcome,
) -> Result<AuthorizationResponse, AuthorizationError>where
Outcome: IntoAuthorizationResponse,
pub fn deny_if_with_user<Outcome>(
&self,
check: impl FnOnce(&User) -> Outcome,
) -> Result<AuthorizationResponse, AuthorizationError>where
Outcome: IntoAuthorizationResponse,
Perform an authenticated-user inline deny check without registered hooks.
Sourcepub fn deny_if_for_guests<Outcome>(
&self,
check: impl FnOnce(Option<&User>) -> Outcome,
) -> Result<AuthorizationResponse, AuthorizationError>where
Outcome: IntoAuthorizationResponse,
pub fn deny_if_for_guests<Outcome>(
&self,
check: impl FnOnce(Option<&User>) -> Outcome,
) -> Result<AuthorizationResponse, AuthorizationError>where
Outcome: IntoAuthorizationResponse,
Perform a guest-aware inline deny check without registered hooks.
Auto Trait Implementations§
impl<User> !RefUnwindSafe for UserGate<User>
impl<User> !UnwindSafe for UserGate<User>
impl<User> Forget for UserGate<User>
impl<User> Freeze for UserGate<User>
impl<User> Move for UserGate<User>
impl<User> Send for UserGate<User>
impl<User> Sync for UserGate<User>
impl<User> Unpin for UserGate<User>
impl<User> UnsafeUnpin for UserGate<User>
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
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> ⓘ
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