pub struct JsonRequestBuilder<T> { /* private fields */ }Expand description
表示通用 JSON 请求构建器。
Implementations§
Source§impl<T> JsonRequestBuilder<T>
impl<T> JsonRequestBuilder<T>
Sourcepub fn body_value(self, body: impl Into<JsonPayload>) -> Self
pub fn body_value(self, body: impl Into<JsonPayload>) -> Self
设置整个请求体为一个 serde_json::Value。
Sourcepub fn extra_header(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn extra_header( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
添加一个额外请求头。
Sourcepub fn remove_header(self, key: impl Into<String>) -> Self
pub fn remove_header(self, key: impl Into<String>) -> Self
删除一个默认请求头。
Sourcepub fn extra_query(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn extra_query( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
添加一个额外查询参数。
Sourcepub fn extra_body(
self,
key: impl Into<String>,
value: impl Into<JsonPayload>,
) -> Self
pub fn extra_body( self, key: impl Into<String>, value: impl Into<JsonPayload>, ) -> Self
在 JSON 根对象中追加字段。
Sourcepub fn provider_option(
self,
key: impl Into<String>,
value: impl Into<JsonPayload>,
) -> Self
pub fn provider_option( self, key: impl Into<String>, value: impl Into<JsonPayload>, ) -> Self
在 provider 对应的 provider_options 下追加字段。
Sourcepub fn max_retries(self, max_retries: u32) -> Self
pub fn max_retries(self, max_retries: u32) -> Self
覆盖最大重试次数。
Sourcepub fn cancellation_token(self, token: CancellationToken) -> Self
pub fn cancellation_token(self, token: CancellationToken) -> Self
设置取消令牌。
Sourcepub fn multipart_text(
self,
name: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn multipart_text( self, name: impl Into<String>, value: impl Into<String>, ) -> Self
添加 Multipart 文本字段。
Sourcepub fn multipart_file(self, name: impl Into<String>, file: UploadSource) -> Self
pub fn multipart_file(self, name: impl Into<String>, file: UploadSource) -> Self
添加 Multipart 文件字段。
Source§impl<T> JsonRequestBuilder<T>where
T: DeserializeOwned,
impl<T> JsonRequestBuilder<T>where
T: DeserializeOwned,
Sourcepub async fn send_with_meta(self) -> Result<ApiResponse<T>>
pub async fn send_with_meta(self) -> Result<ApiResponse<T>>
Sourcepub async fn send_raw_sse(self) -> Result<RawSseStream>
pub async fn send_raw_sse(self) -> Result<RawSseStream>
Source§impl<T> JsonRequestBuilder<T>where
T: DeserializeOwned + Send + 'static,
impl<T> JsonRequestBuilder<T>where
T: DeserializeOwned + Send + 'static,
Trait Implementations§
Source§impl<T: Clone> Clone for JsonRequestBuilder<T>
impl<T: Clone> Clone for JsonRequestBuilder<T>
Source§fn clone(&self) -> JsonRequestBuilder<T>
fn clone(&self) -> JsonRequestBuilder<T>
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<T> Freeze for JsonRequestBuilder<T>
impl<T> !RefUnwindSafe for JsonRequestBuilder<T>
impl<T> Send for JsonRequestBuilder<T>where
T: Send,
impl<T> Sync for JsonRequestBuilder<T>where
T: Sync,
impl<T> Unpin for JsonRequestBuilder<T>where
T: Unpin,
impl<T> UnsafeUnpin for JsonRequestBuilder<T>
impl<T> !UnwindSafe for JsonRequestBuilder<T>
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