pub struct Client<Req, Resp>{ /* private fields */ }Expand description
A client for sending requests and receiving responses.
The client is thread-safe and can be cloned to share across multiple tasks. It supports both single and batch requests, with configurable timeouts.
§Type Parameters
Req: The type of the request, must beSend + Sync + 'static.Resp: The type of the response, must beSend + Sync + 'static.
Implementations§
Source§impl<Req, Resp> Client<Req, Resp>
impl<Req, Resp> Client<Req, Resp>
Sourcepub async fn request_timeout(
&self,
req: Req,
timeout: Duration,
) -> Result<Resp, Error>
pub async fn request_timeout( &self, req: Req, timeout: Duration, ) -> Result<Resp, Error>
Sourcepub async fn request_batch_timeout<ReqSeq>(
&self,
reqs: ReqSeq,
timeout: Duration,
concurrency: usize,
) -> Result<Vec<Resp>, Error>where
ReqSeq: IntoIterator<Item = Req> + Send + 'static,
pub async fn request_batch_timeout<ReqSeq>(
&self,
reqs: ReqSeq,
timeout: Duration,
concurrency: usize,
) -> Result<Vec<Resp>, Error>where
ReqSeq: IntoIterator<Item = Req> + Send + 'static,
Sends a batch of requests with a custom timeout and concurrency limit.
§Parameters
reqs: An iterator of requests to send.timeout: The maximum duration to wait for all responses.concurrency: The maximum number of concurrent requests.
§Returns
Ok(Vec<Resp>): A vector of responses from the server.Err(Error): An error if any request fails or times out.
Sourcepub async fn request_batch<ReqSeq>(
&self,
reqs: ReqSeq,
concurrency: usize,
) -> Result<Vec<Resp>, Error>where
ReqSeq: IntoIterator<Item = Req> + Send + 'static,
pub async fn request_batch<ReqSeq>(
&self,
reqs: ReqSeq,
concurrency: usize,
) -> Result<Vec<Resp>, Error>where
ReqSeq: IntoIterator<Item = Req> + Send + 'static,
Sends a batch of requests with the default timeout and a concurrency limit.
§Parameters
reqs: An iterator of requests to send.concurrency: The maximum number of concurrent requests.
§Returns
Ok(Vec<Resp>): A vector of responses from the server.Err(Error): An error if any request fails or times out.
Trait Implementations§
Auto Trait Implementations§
impl<Req, Resp> Freeze for Client<Req, Resp>
impl<Req, Resp> !RefUnwindSafe for Client<Req, Resp>
impl<Req, Resp> Send for Client<Req, Resp>
impl<Req, Resp> Sync for Client<Req, Resp>
impl<Req, Resp> Unpin for Client<Req, Resp>
impl<Req, Resp> !UnwindSafe for Client<Req, Resp>
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