Macro apisdk::send_xml

source ·
macro_rules! send_xml {
    ($req:expr, $xml:expr) => { ... };
    ($req:expr, $xml:expr, ()) => { ... };
    ($req:expr, $xml:expr, Body) => { ... };
    ($req:expr, $xml:expr, Json) => { ... };
    ($req:expr, $xml:expr, Xml) => { ... };
    ($req:expr, $xml:expr, Text) => { ... };
    ($req:expr, $xml:expr, $parser:ty, ()) => { ... };
    ($req:expr, $xml:expr, Json<$ve:ty>) => { ... };
    ($req:expr, $xml:expr, $ve:ty) => { ... };
    ($req:expr, $xml:expr, $parser:ty, $vet:ty, $ve:ty) => { ... };
}
Expand description

Send the payload as XML, which will be serialized by quick_xml

§Forms

  • send_xml!(req, xml) -> impl Future<Output = ApiResult<T>>
    • send xml, and parse response as json or xml based on response
  • send_xml!(req, xml, ()) -> impl Future<Output = ApiResult<()>>
    • send xml, verify response status, then discard response
  • send_xml!(req, xml, Body) -> impl Future<Output = ApiResult<apisdk::ResponseBody>>
    • send xml, verify response status, and decode response body
  • send_xml!(req, xml, Json) -> impl Future<Output = ApiResult<T>>
    • send the request, parse response as json, then use serde_json to deserialize it
  • send_xml!(req, xml, Xml) -> impl Future<Output = ApiResult<T>>
    • send the request, parse response as xml, then use quick_xml to deserialize it
  • send_xml!(req, xml, Text) -> impl Future<Output = ApiResult<T>>
    • send the request, parse response as text, then use FromStr to deserialize it
  • send_xml!(req, xml, OtherType) -> impl Future<Output = ApiResult<T>>
    • send xml, parse response as json, and use OtherType as JsonExtractor
  • send_xml!(req, xml, Json<OtherType>) -> impl Future<Output = ApiResult<T>>
    • send xml, parse response as json, and use OtherType as JsonExtractor

§Examples

#[derive(serde::Serialize)]
struct Data {
    key: String,
}

let data = Data { key: "value".to_string() };
let req = client.post("/path/api").await?;
let res: TypeOfResponse = send_xml!(req, data).await?;

Please reference send for more information