pub trait HttpAdapterTrait: Send + Sync {
// Required methods
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
url: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn post<'life0, 'life1, 'async_trait>(
&'life0 self,
url: &'life1 str,
body: Value,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn post_stream<'life0, 'life1, 'async_trait>(
&'life0 self,
url: &'life1 str,
body: Value,
) -> Pin<Box<dyn Future<Output = Result<HttpResponseStream>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn post_sse<'life0, 'life1, 'async_trait>(
&'life0 self,
url: &'life1 str,
body: Value,
) -> Pin<Box<dyn Future<Output = Result<SseStream>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
HTTP 适配器 trait
定义 HTTP 请求的标准接口
Required Methods§
Sourcefn get<'life0, 'life1, 'async_trait>(
&'life0 self,
url: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
url: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
执行 HTTP GET 请求
Sourcefn post<'life0, 'life1, 'async_trait>(
&'life0 self,
url: &'life1 str,
body: Value,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn post<'life0, 'life1, 'async_trait>(
&'life0 self,
url: &'life1 str,
body: Value,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
执行 HTTP POST 请求
Sourcefn post_stream<'life0, 'life1, 'async_trait>(
&'life0 self,
url: &'life1 str,
body: Value,
) -> Pin<Box<dyn Future<Output = Result<HttpResponseStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn post_stream<'life0, 'life1, 'async_trait>(
&'life0 self,
url: &'life1 str,
body: Value,
) -> Pin<Box<dyn Future<Output = Result<HttpResponseStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
执行流式 HTTP POST 请求
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".