pub struct ErrorResponse<Meta> {
pub error: ApiError,
pub meta: Option<Meta>,
}
Expand description
Struct to represent an error response
Fields§
§error: ApiError
§meta: Option<Meta>
Implementations§
Source§impl<Meta> ErrorResponse<Meta>
impl<Meta> ErrorResponse<Meta>
pub fn new(error: ApiError, meta: Option<Meta>) -> Self
pub fn from_error(error: ApiError) -> Self
pub fn from_error_msg(code: i32, message: impl Into<String>) -> Self
pub fn from_error_source( code: i32, source: impl Error + Send + Sync + 'static, message: Option<String>, ) -> Self
pub fn with_meta(self, meta: Meta) -> Self
pub fn set_meta(&mut self, meta: Meta) -> &mut Self
pub fn with_detail( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
pub fn set_detail( &mut self, key: impl Into<String>, value: impl Into<String>, ) -> &mut Self
pub fn with_source(self, source: impl Error + Send + Sync + 'static) -> Self
pub fn set_source( &mut self, source: impl Error + Send + Sync + 'static, ) -> &mut Self
pub fn is<E: Error + 'static>(&self) -> bool
pub fn downcast_ref<E: Error + 'static>(&self) -> Option<&E>
Trait Implementations§
Source§impl<Meta: Debug> Debug for ErrorResponse<Meta>
impl<Meta: Debug> Debug for ErrorResponse<Meta>
Source§impl<'de, Meta> Deserialize<'de> for ErrorResponse<Meta>where
Meta: Deserialize<'de>,
impl<'de, Meta> Deserialize<'de> for ErrorResponse<Meta>where
Meta: Deserialize<'de>,
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<Meta> Display for ErrorResponse<Meta>
impl<Meta> Display for ErrorResponse<Meta>
Source§impl<Meta: Debug> Error for ErrorResponse<Meta>
impl<Meta: Debug> Error for ErrorResponse<Meta>
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<Meta> From<ApiError> for ErrorResponse<Meta>
impl<Meta> From<ApiError> for ErrorResponse<Meta>
Source§impl<Data, Meta> From<ErrorResponse<Meta>> for ApiResponse<Data, Meta>
impl<Data, Meta> From<ErrorResponse<Meta>> for ApiResponse<Data, Meta>
Source§fn from(value: ErrorResponse<Meta>) -> Self
fn from(value: ErrorResponse<Meta>) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl<Meta> Freeze for ErrorResponse<Meta>where
Meta: Freeze,
impl<Meta> !RefUnwindSafe for ErrorResponse<Meta>
impl<Meta> Send for ErrorResponse<Meta>where
Meta: Send,
impl<Meta> Sync for ErrorResponse<Meta>where
Meta: Sync,
impl<Meta> Unpin for ErrorResponse<Meta>where
Meta: Unpin,
impl<Meta> !UnwindSafe for ErrorResponse<Meta>
Blanket Implementations§
Source§impl<Data> ApiSuccessResponse for Data
impl<Data> ApiSuccessResponse for Data
fn api_success_response<Meta>( self, meta: Option<Meta>, ) -> ApiResponse<Self, Meta>
fn api_success_without_meta<Meta>(self) -> ApiResponse<Self, Meta>
fn api_success_with_meta<Meta>(self, meta: Meta) -> ApiResponse<Self, Meta>
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