pub struct RequestClient { /* private fields */ }Expand description
兼容旧 API 的 RequestClient
Implementations§
Source§impl RequestClient
impl RequestClient
Sourcepub fn new(config: RequestConfig) -> WaeResult<Self>
pub fn new(config: RequestConfig) -> WaeResult<Self>
创建新的 HTTP 客户端
Sourcepub fn with_defaults() -> WaeResult<Self>
pub fn with_defaults() -> WaeResult<Self>
使用默认配置创建
Sourcepub fn config(&self) -> &RequestConfig
pub fn config(&self) -> &RequestConfig
获取配置
Sourcepub async fn get<T: DeserializeOwned>(&self, url: &str) -> WaeResult<T>
pub async fn get<T: DeserializeOwned>(&self, url: &str) -> WaeResult<T>
发送 GET 请求并解析 JSON
Sourcepub async fn get_raw(&self, url: &str) -> WaeResult<HttpResponse>
pub async fn get_raw(&self, url: &str) -> WaeResult<HttpResponse>
发送 GET 请求返回原始响应
Sourcepub async fn post<T: DeserializeOwned, B: Serialize>(
&self,
url: &str,
body: &B,
) -> WaeResult<T>
pub async fn post<T: DeserializeOwned, B: Serialize>( &self, url: &str, body: &B, ) -> WaeResult<T>
发送 POST JSON 请求并解析响应
Sourcepub async fn post_raw<B: Serialize>(
&self,
url: &str,
body: &B,
) -> WaeResult<HttpResponse>
pub async fn post_raw<B: Serialize>( &self, url: &str, body: &B, ) -> WaeResult<HttpResponse>
发送 POST JSON 请求返回原始响应
Sourcepub fn builder(&self) -> RequestBuilder
pub fn builder(&self) -> RequestBuilder
创建请求构建器
Trait Implementations§
Source§impl Clone for RequestClient
impl Clone for RequestClient
Source§fn clone(&self) -> RequestClient
fn clone(&self) -> RequestClient
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for RequestClient
impl RefUnwindSafe for RequestClient
impl Send for RequestClient
impl Sync for RequestClient
impl Unpin for RequestClient
impl UnsafeUnpin for RequestClient
impl UnwindSafe for RequestClient
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