alibaba_cloud_sdk_rust/sdk/responses/
mod.rs1#![allow(unused)]
2#![allow(non_upper_case_globals)]
3#![allow(non_snake_case)]
4#![allow(non_camel_case_types)]
5use crate::error::AliyunResult;
6use crate::error::AliyunSDKError::AliyunSMSError;
7use gostd::net::http;
8use std::collections::HashMap;
9pub type AcsResponse = BaseResponse;
10
11#[derive(Default, Debug)]
12pub struct BaseResponse {
13 pub httpStatus: i32,
14 pub httpHeaders: HashMap<String, Vec<String>>,
15 pub httpContentString: String,
16 pub httpContentBytes: Vec<u8>,
17 originHttpResponse: http::Response,
18}
19
20impl BaseResponse {
21 pub fn parseFromHttpResponse(&mut self, httpResponse: &http::Response) -> AliyunResult<()> {
22 if let Some(bytesBody) = &httpResponse.Body {
23 self.httpStatus = httpResponse.StatusCode as i32;
24 self.httpContentBytes = bytesBody.to_vec();
25 self.httpContentString = String::from_utf8(bytesBody.to_vec())?;
26 self.originHttpResponse = httpResponse.to_owned();
27 Ok(())
28 } else {
29 Err(AliyunSMSError("http response body is NONE".to_string()))
30 }
31 }
32}