pub struct ErrorTestView {
pub error_message: String,
pub error_kind: ErrorKind,
}Expand description
Create a view that always returns an error for testing error handling
Fields§
§error_message: StringThe error message to return.
error_kind: ErrorKindThe kind of error to return.
Implementations§
Source§impl ErrorTestView
impl ErrorTestView
Sourcepub fn new(error_message: String, error_kind: ErrorKind) -> ErrorTestView
pub fn new(error_message: String, error_kind: ErrorKind) -> ErrorTestView
Create a new ErrorTestView with the given message and error kind.
Sourcepub fn not_found(message: impl Into<String>) -> ErrorTestView
pub fn not_found(message: impl Into<String>) -> ErrorTestView
Create an ErrorTestView that returns a 404 Not Found error.
Sourcepub fn validation(message: impl Into<String>) -> ErrorTestView
pub fn validation(message: impl Into<String>) -> ErrorTestView
Create an ErrorTestView that returns a validation error.
Trait Implementations§
Source§impl View for ErrorTestView
impl View for ErrorTestView
Source§fn dispatch<'life0, 'async_trait>(
&'life0 self,
_request: Request,
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
ErrorTestView: 'async_trait,
fn dispatch<'life0, 'async_trait>(
&'life0 self,
_request: Request,
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
ErrorTestView: 'async_trait,
Dispatch the request and return a response.
Source§fn allowed_methods(&self) -> Vec<&'static str>
fn allowed_methods(&self) -> Vec<&'static str>
Returns the list of HTTP methods allowed by this view
Auto Trait Implementations§
impl Freeze for ErrorTestView
impl RefUnwindSafe for ErrorTestView
impl Send for ErrorTestView
impl Sync for ErrorTestView
impl Unpin for ErrorTestView
impl UnsafeUnpin for ErrorTestView
impl UnwindSafe for ErrorTestView
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> 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