pub enum ApiResponse<Data, Meta> {
Success(SuccessResponse<Data, Meta>),
Error(ErrorResponse<Meta>),
}
Expand description
Enum to represent the overall API response
Variants§
Success(SuccessResponse<Data, Meta>)
Error(ErrorResponse<Meta>)
Implementations§
Source§impl<Data, Meta> ApiResponse<Data, Meta>
impl<Data, Meta> ApiResponse<Data, Meta>
pub fn new_success(data: Data, meta: Option<Meta>) -> Self
pub fn from_success(data: Data, meta: Meta) -> Self
pub fn from_success_data(data: Data) -> Self
pub fn new_error(error: ErrorInfo, meta: Option<Meta>) -> Self
pub fn from_error(error: ErrorInfo, meta: Meta) -> Self
pub fn from_error_info(code: i32, message: impl Into<String>) -> Self
pub fn with_meta(self, meta: Meta) -> Self
pub fn set_meta(&mut self, meta: Meta) -> &mut Self
pub fn is_success(&self) -> bool
pub fn is_error(&self) -> bool
pub fn get_meta(&self) -> Option<&Meta>
pub fn into_result(self) -> ApiResult<Data, Meta>
pub fn into_result_data(self) -> Result<Data, ErrorResponse<Meta>>
Trait Implementations§
Source§impl<'de, Data, Meta> Deserialize<'de> for ApiResponse<Data, Meta>where
Data: Deserialize<'de>,
Meta: Deserialize<'de>,
impl<'de, Data, Meta> Deserialize<'de> for ApiResponse<Data, Meta>where
Data: Deserialize<'de>,
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<Data, Meta> From<(Data, Meta)> for ApiResponse<Data, Meta>
impl<Data, Meta> From<(Data, Meta)> for ApiResponse<Data, Meta>
Source§fn from((data, meta): (Data, Meta)) -> Self
fn from((data, meta): (Data, Meta)) -> Self
Converts to this type from the input type.
Source§impl<Data, Meta> From<ApiResponse<Data, Meta>> for Result<Data, ErrorInfo>
impl<Data, Meta> From<ApiResponse<Data, Meta>> for Result<Data, ErrorInfo>
Source§fn from(api_response: ApiResponse<Data, Meta>) -> Self
fn from(api_response: ApiResponse<Data, Meta>) -> Self
Converts to this type from the input type.
Source§impl<Data, Meta> From<ApiResponse<Data, Meta>> for ApiResult<Data, Meta>
impl<Data, Meta> From<ApiResponse<Data, Meta>> for ApiResult<Data, Meta>
Source§fn from(api_response: ApiResponse<Data, Meta>) -> Self
fn from(api_response: ApiResponse<Data, Meta>) -> Self
Converts to this type from the input type.
Source§impl<Data, Meta> From<ErrorInfo> for ApiResponse<Data, Meta>
impl<Data, Meta> From<ErrorInfo> for ApiResponse<Data, 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.
Source§impl<Data, Meta> From<Result<SuccessResponse<Data, Meta>, ErrorResponse<Meta>>> for ApiResponse<Data, Meta>where
Meta: Default,
impl<Data, Meta> From<Result<SuccessResponse<Data, Meta>, ErrorResponse<Meta>>> for ApiResponse<Data, Meta>where
Meta: Default,
Source§impl<Data, Meta> From<SuccessResponse<Data, Meta>> for ApiResponse<Data, Meta>
impl<Data, Meta> From<SuccessResponse<Data, Meta>> for ApiResponse<Data, Meta>
Source§fn from(value: SuccessResponse<Data, Meta>) -> Self
fn from(value: SuccessResponse<Data, Meta>) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl<Data, Meta> Freeze for ApiResponse<Data, Meta>
impl<Data, Meta> !RefUnwindSafe for ApiResponse<Data, Meta>
impl<Data, Meta> Send for ApiResponse<Data, Meta>
impl<Data, Meta> Sync for ApiResponse<Data, Meta>
impl<Data, Meta> Unpin for ApiResponse<Data, Meta>
impl<Data, Meta> !UnwindSafe for ApiResponse<Data, Meta>
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