pub struct Client { /* private fields */ }Expand description
HTTP 客户端,封装 reqwest Client,提供带拦截器链和并发限制的请求方法。
Implementations§
Source§impl Client
impl Client
Sourcepub async fn request_raw<Q, P>(
&self,
params: Params<'_, Q, P>,
) -> Result<Bytes, Error>
pub async fn request_raw<Q, P>( &self, params: Params<'_, Q, P>, ) -> Result<Bytes, Error>
发送请求并返回原始响应字节,不进行 JSON 反序列化。
Sourcepub async fn get<T>(&self, url: &str) -> Result<T, Error>where
T: DeserializeOwned,
pub async fn get<T>(&self, url: &str) -> Result<T, Error>where
T: DeserializeOwned,
发送 GET 请求并将响应反序列化为 T。
Sourcepub async fn get_with_query<P, T>(
&self,
url: &str,
query: &P,
) -> Result<T, Error>
pub async fn get_with_query<P, T>( &self, url: &str, query: &P, ) -> Result<T, Error>
发送带查询参数的 GET 请求并将响应反序列化为 T。
Sourcepub async fn post<P, T>(&self, url: &str, json: &P) -> Result<T, Error>
pub async fn post<P, T>(&self, url: &str, json: &P) -> Result<T, Error>
发送带 JSON 请求体的 POST 请求并将响应反序列化为 T。
Sourcepub async fn post_with_query<P, Q, T>(
&self,
url: &str,
json: &P,
query: &Q,
) -> Result<T, Error>
pub async fn post_with_query<P, Q, T>( &self, url: &str, json: &P, query: &Q, ) -> Result<T, Error>
发送带 JSON 请求体和查询参数的 POST 请求并将响应反序列化为 T。
Sourcepub async fn put<P, T>(&self, url: &str, json: &P) -> Result<T, Error>
pub async fn put<P, T>(&self, url: &str, json: &P) -> Result<T, Error>
发送带 JSON 请求体的 PUT 请求并将响应反序列化为 T。
Sourcepub async fn patch<P, T>(&self, url: &str, json: &P) -> Result<T, Error>
pub async fn patch<P, T>(&self, url: &str, json: &P) -> Result<T, Error>
发送带 JSON 请求体的 PATCH 请求并将响应反序列化为 T。
Sourcepub async fn delete<T>(&self, url: &str) -> Result<T, Error>where
T: DeserializeOwned,
pub async fn delete<T>(&self, url: &str) -> Result<T, Error>where
T: DeserializeOwned,
发送 DELETE 请求并将响应反序列化为 T。
Sourcepub fn get_processing(&self) -> u32
pub fn get_processing(&self) -> u32
获取当前在途请求数。
Auto Trait Implementations§
impl !Freeze for Client
impl !RefUnwindSafe for Client
impl !UnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnsafeUnpin for Client
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