#[non_exhaustive]pub enum AuthzError {
Unauthorized {
reason: String,
},
Forbidden {
reason: String,
},
RateLimited {
reason: String,
},
InvalidRole {
name: String,
},
InvalidResource {
name: String,
},
}Expand description
Errors that can occur during authorization operations.
use stateset_authz::AuthzError;
let err = AuthzError::unauthorized("missing API key");
assert!(err.to_string().contains("missing API key"));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
The actor is not authenticated (401).
Fields
Why authentication failed.
Forbidden
The actor is authenticated but lacks permission (403).
RateLimited
The actor has exceeded their rate limit (429).
InvalidRole
An invalid role was referenced.
InvalidResource
An invalid resource was referenced.
Implementations§
Source§impl AuthzError
impl AuthzError
Creates an Unauthorized error.
Sourcepub fn rate_limited(reason: impl Into<String>) -> Self
pub fn rate_limited(reason: impl Into<String>) -> Self
Creates a RateLimited error.
Sourcepub fn invalid_role(name: impl Into<String>) -> Self
pub fn invalid_role(name: impl Into<String>) -> Self
Creates an InvalidRole error.
Sourcepub fn invalid_resource(name: impl Into<String>) -> Self
pub fn invalid_resource(name: impl Into<String>) -> Self
Creates an InvalidResource error.
Returns true if this is an unauthorized error.
Sourcepub const fn is_forbidden(&self) -> bool
pub const fn is_forbidden(&self) -> bool
Returns true if this is a forbidden error.
Sourcepub const fn is_rate_limited(&self) -> bool
pub const fn is_rate_limited(&self) -> bool
Returns true if this is a rate limited error.
Trait Implementations§
Source§impl Clone for AuthzError
impl Clone for AuthzError
Source§fn clone(&self) -> AuthzError
fn clone(&self) -> AuthzError
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for AuthzError
impl Debug for AuthzError
Source§impl<'de> Deserialize<'de> for AuthzError
impl<'de> Deserialize<'de> for AuthzError
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for AuthzError
impl Display for AuthzError
impl Eq for AuthzError
Source§impl Error for AuthzError
impl Error for AuthzError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl PartialEq for AuthzError
impl PartialEq for AuthzError
Source§impl Serialize for AuthzError
impl Serialize for AuthzError
impl StructuralPartialEq for AuthzError
Auto Trait Implementations§
impl Freeze for AuthzError
impl RefUnwindSafe for AuthzError
impl Send for AuthzError
impl Sync for AuthzError
impl Unpin for AuthzError
impl UnsafeUnpin for AuthzError
impl UnwindSafe for AuthzError
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