pub struct OAuthError {
pub error: String,
pub error_description: Option<String>,
pub error_uri: Option<String>,
pub state: Option<String>,
}Expand description
OAuth error response per RFC 6749 §5.2.
Use the constructor + chaining helpers to avoid specifying all four fields every time:
§Example
use auth_framework::api::oauth2::OAuthError;
let err = OAuthError::new("invalid_request")
.description("missing redirect_uri")
.state("abc");
assert_eq!(err.error, "invalid_request");
assert_eq!(err.error_description.as_deref(), Some("missing redirect_uri"));Fields§
§error: String§error_description: Option<String>§error_uri: Option<String>§state: Option<String>Implementations§
Source§impl OAuthError
impl OAuthError
Sourcepub fn new(error: impl Into<String>) -> Self
pub fn new(error: impl Into<String>) -> Self
Create a new error with the given error code (e.g. "invalid_request").
Sourcepub fn description(self, desc: impl Into<String>) -> Self
pub fn description(self, desc: impl Into<String>) -> Self
Set the human-readable error description.
Sourcepub fn state(self, state: impl Into<String>) -> Self
pub fn state(self, state: impl Into<String>) -> Self
Set the state parameter (echoed back from the authorization request).
Sourcepub fn maybe_state(self, state: Option<String>) -> Self
pub fn maybe_state(self, state: Option<String>) -> Self
Set the state parameter from an Option.
Trait Implementations§
Source§impl Debug for OAuthError
impl Debug for OAuthError
Auto Trait Implementations§
impl Freeze for OAuthError
impl RefUnwindSafe for OAuthError
impl Send for OAuthError
impl Sync for OAuthError
impl Unpin for OAuthError
impl UnsafeUnpin for OAuthError
impl UnwindSafe for OAuthError
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> 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