pub struct Auth {
pub user_id: i32,
pub roles: HashSet<String>,
pub permissions: HashSet<Permission>,
}
Expand description
roles and permissions available to a User
use to control what users are and are not allowed to do
Fields§
§user_id: i32
§roles: HashSet<String>
§permissions: HashSet<Permission>
Implementations§
Source§impl Auth
impl Auth
Sourcepub fn has_permission(&self, permission: String) -> bool
pub fn has_permission(&self, permission: String) -> bool
does the user with the id self.user_id
have the given permission
Sourcepub fn has_all_permissions(&self, perms: impl AsRef<[String]>) -> bool
pub fn has_all_permissions(&self, perms: impl AsRef<[String]>) -> bool
does the user with the id self.user_id
have all of the given perms
Sourcepub fn has_any_permission(&self, perms: impl AsRef<[String]>) -> bool
pub fn has_any_permission(&self, perms: impl AsRef<[String]>) -> bool
does the user with the id self.user_id
have any of the given perms
Sourcepub fn has_role(&self, role: impl AsRef<str>) -> bool
pub fn has_role(&self, role: impl AsRef<str>) -> bool
does the user with the id self.user_id
have the given role
Sourcepub fn has_all_roles(&self, roles: impl AsRef<[String]>) -> bool
pub fn has_all_roles(&self, roles: impl AsRef<[String]>) -> bool
does the user with the id self.user_id
have all of the given roles
Sourcepub fn has_any_roles(&self, roles: impl AsRef<[String]>) -> bool
pub fn has_any_roles(&self, roles: impl AsRef<[String]>) -> bool
does the user with the id self.user_id
have any of the given roles
Trait Implementations§
Source§impl FromRequest for Auth
impl FromRequest for Auth
Source§fn from_request(
req: &HttpRequest,
_payload: &mut Payload,
) -> <Self as FromRequest>::Future
fn from_request( req: &HttpRequest, _payload: &mut Payload, ) -> <Self as FromRequest>::Future
Auto Trait Implementations§
impl Freeze for Auth
impl RefUnwindSafe for Auth
impl Send for Auth
impl Sync for Auth
impl Unpin for Auth
impl UnwindSafe for Auth
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 moreSource§impl<T> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
Convert
self
to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
Convert
&self
to an expression for Diesel’s query builder. Read more