pub struct AuthDeny {
pub reason: String,
pub code: AuthErrorCode,
pub details: AuthErrorDetails,
pub retry_policy: RetryPolicy,
pub http_status: u16,
pub reset_at: Option<SystemTime>,
}Expand description
Enhanced authentication denial with structured error information
Fields§
§reason: String§code: AuthErrorCode§details: AuthErrorDetailsStructured error details for machine processing
retry_policy: RetryPolicyRetry policy hint
http_status: u16HTTP status code equivalent for the error
reset_at: Option<SystemTime>When the error condition will reset (if applicable)
Implementations§
Source§impl AuthDeny
impl AuthDeny
Sourcepub fn new(code: AuthErrorCode, reason: impl Into<String>) -> Self
pub fn new(code: AuthErrorCode, reason: impl Into<String>) -> Self
Create a new AuthDeny with the specified error code and reason
Sourcepub fn token_missing() -> Self
pub fn token_missing() -> Self
Create an AuthDeny for missing token
Sourcepub fn from_verify_error(err: VerifyError) -> Self
pub fn from_verify_error(err: VerifyError) -> Self
Create an AuthDeny from a VerifyError
Sourcepub fn with_details(self, details: AuthErrorDetails) -> Self
pub fn with_details(self, details: AuthErrorDetails) -> Self
Add structured error details
Sourcepub fn with_field(self, field: impl Into<String>) -> Self
pub fn with_field(self, field: impl Into<String>) -> Self
Add a specific field that caused the error
Sourcepub fn with_context(self, context: impl Into<String>) -> Self
pub fn with_context(self, context: impl Into<String>) -> Self
Add context to the error
Sourcepub fn with_suggested_action(self, action: impl Into<String>) -> Self
pub fn with_suggested_action(self, action: impl Into<String>) -> Self
Add a suggested action for the client
Sourcepub fn with_docs_url(self, url: impl Into<String>) -> Self
pub fn with_docs_url(self, url: impl Into<String>) -> Self
Add documentation URL
Sourcepub fn with_retry_policy(self, policy: RetryPolicy) -> Self
pub fn with_retry_policy(self, policy: RetryPolicy) -> Self
Set a custom retry policy
Sourcepub fn with_reset_at(self, reset_at: SystemTime) -> Self
pub fn with_reset_at(self, reset_at: SystemTime) -> Self
Set when the error condition will reset
Sourcepub fn rate_limited(retry_after: Duration, limit_type: &str) -> Self
pub fn rate_limited(retry_after: Duration, limit_type: &str) -> Self
Create an AuthDeny for rate limiting with retry information
Sourcepub fn connection_limit_exceeded(
limit_type: &str,
current: usize,
max: usize,
) -> Self
pub fn connection_limit_exceeded( limit_type: &str, current: usize, max: usize, ) -> Self
Create an AuthDeny for connection limits
Sourcepub fn to_error_response(&self) -> ErrorResponse
pub fn to_error_response(&self) -> ErrorResponse
Convert to a JSON-serializable error response
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AuthDeny
impl RefUnwindSafe for AuthDeny
impl Send for AuthDeny
impl Sync for AuthDeny
impl Unpin for AuthDeny
impl UnsafeUnpin for AuthDeny
impl UnwindSafe for AuthDeny
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