#[non_exhaustive]pub struct ApiResponseBase {
pub errcode: i32,
pub errmsg: String,
}Expand description
Minimal API response carrying only errcode and errmsg.
Use this for endpoints that return no data beyond success/failure, or as a lightweight way to inspect the error fields before attempting a full parse.
§Example
use wechat_mp_sdk::api::common::{ApiResponseBase, WechatApiResponse};
let json = r#"{"errcode": 40013, "errmsg": "invalid appid"}"#;
let resp: ApiResponseBase = serde_json::from_str(json).unwrap();
assert!(!resp.is_success());
assert!(resp.check().is_err());Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.errcode: i32Error code (0 = success)
errmsg: StringError message
Implementations§
Trait Implementations§
Source§impl Clone for ApiResponseBase
impl Clone for ApiResponseBase
Source§fn clone(&self) -> ApiResponseBase
fn clone(&self) -> ApiResponseBase
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ApiResponseBase
impl Debug for ApiResponseBase
Source§impl<'de> Deserialize<'de> for ApiResponseBase
impl<'de> Deserialize<'de> for ApiResponseBase
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 Serialize for ApiResponseBase
impl Serialize for ApiResponseBase
Source§impl WechatApiResponse for ApiResponseBase
impl WechatApiResponse for ApiResponseBase
Source§fn is_success(&self) -> bool
fn is_success(&self) -> bool
Returns
true when the response indicates success (errcode == 0).Auto Trait Implementations§
impl Freeze for ApiResponseBase
impl RefUnwindSafe for ApiResponseBase
impl Send for ApiResponseBase
impl Sync for ApiResponseBase
impl Unpin for ApiResponseBase
impl UnsafeUnpin for ApiResponseBase
impl UnwindSafe for ApiResponseBase
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