Struct fml::types::ApiResponse
source · 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> 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