pub struct ApiResponse<T> {
pub error: Option<String>,
pub data: Option<T>,
pub unknown: HashMap<String, Value>,
}Expand description
An API Response
Fields§
§error: Option<String>A potential API error.
Populated on error.
data: Option<T>A potential response payload.
Populated if successful.
unknown: HashMap<String, Value>Unknown data
Implementations§
Source§impl<T> ApiResponse<T>
impl<T> ApiResponse<T>
Sourcepub fn is_error(&self) -> bool
pub fn is_error(&self) -> bool
Whether the response is an error.
This performs a check on the error field.
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Whether the response is a success.
This performs a check on the data field.
Sourcepub fn is_valid_response(&self) -> bool
pub fn is_valid_response(&self) -> bool
Checks whether the data contained is valid.
This looks to see if this is both an error and success or neither.
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for ApiResponse<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for ApiResponse<T>where
T: 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<T> From<ApiResponse<T>> for FmlResult<T>
impl<T> From<ApiResponse<T>> for FmlResult<T>
Source§fn from(response: ApiResponse<T>) -> Self
fn from(response: ApiResponse<T>) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl<T> Freeze for ApiResponse<T>where
T: Freeze,
impl<T> RefUnwindSafe for ApiResponse<T>where
T: RefUnwindSafe,
impl<T> Send for ApiResponse<T>where
T: Send,
impl<T> Sync for ApiResponse<T>where
T: Sync,
impl<T> Unpin for ApiResponse<T>where
T: Unpin,
impl<T> UnwindSafe for ApiResponse<T>where
T: UnwindSafe,
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