Skip to main content

RequestExecutor

Trait RequestExecutor 

Source
pub trait RequestExecutor<T, E>: Send + Sync {
    // Required method
    fn execute<'life0, 'life1, 'async_trait>(
        &'life0 self,
        uri: &'life1 str,
        data: E,
        wx_type: WxType,
    ) -> Pin<Box<dyn Future<Output = Result<T, WxErrorException>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

HTTP 请求执行器策略。

对应 Java RequestExecutor<T, E> 接口;在 Rust 中以 async trait 表达。 每个 Java 执行器类(SimpleGet/Post、MediaUpload/Download 等)对应一个 Rust 实现结构体,持有 reqwest::Client

§类型参数

  • T:返回值类型
  • E:请求参数类型

Required Methods§

Source

fn execute<'life0, 'life1, 'async_trait>( &'life0 self, uri: &'life1 str, data: E, wx_type: WxType, ) -> Pin<Box<dyn Future<Output = Result<T, WxErrorException>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

执行 HTTP 请求。

§参数
  • uri:请求 URI(已含 access_token)
  • data:请求数据
  • wx_type:微信模块类型
§返回

响应结果。

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§