pub struct ReqwestClient { /* private fields */ }Implementations§
Source§impl ReqwestClient
impl ReqwestClient
pub fn new() -> Self
pub fn user_agent(agent: &str) -> Result<Self>
pub fn proxy_and_user_agent( proxy: Option<Url>, user_agent: &str, ) -> Result<Self>
Sourcepub fn proxy_user_agent_and_read_timeout(
proxy: Option<Url>,
user_agent: &str,
read_timeout: Option<Duration>,
) -> Result<Self>
pub fn proxy_user_agent_and_read_timeout( proxy: Option<Url>, user_agent: &str, read_timeout: Option<Duration>, ) -> Result<Self>
Like ReqwestClient::proxy_and_user_agent, but also applies a
per-read idle timeout. read_timeout fires only after that long with no
bytes received on a response body and resets on every chunk, so it
aborts a silently stalled stream without disturbing a healthy one that
merely goes quiet between chunks. Callers streaming long-lived responses
(e.g. LLM completions, which can pause for tens of seconds during
provider-side reasoning while keep-alive bytes still flow) should size
it comfortably above the provider’s keep-alive interval.
Note: on macOS the timeout is measured against a monotonic clock that pauses during system sleep, so it does not fire from a suspend alone; callers that need prompt detection of a connection killed while suspended must re-validate the stream on wake themselves.
Trait Implementations§
Source§impl From<Client> for ReqwestClient
impl From<Client> for ReqwestClient
Source§impl HttpClient for ReqwestClient
impl HttpClient for ReqwestClient
fn proxy(&self) -> Option<&Url>
fn user_agent(&self) -> Option<&HeaderValue>
fn send( &self, req: Request<AsyncBody>, ) -> BoxFuture<'static, Result<Response<AsyncBody>>>
fn get( &self, uri: &str, body: AsyncBody, follow_redirects: bool, ) -> Pin<Box<dyn Future<Output = Result<Response<AsyncBody>, Error>> + Send>>
fn post_json( &self, uri: &str, body: AsyncBody, ) -> Pin<Box<dyn Future<Output = Result<Response<AsyncBody>, Error>> + Send>>
Auto Trait Implementations§
impl !Freeze for ReqwestClient
impl !RefUnwindSafe for ReqwestClient
impl !UnwindSafe for ReqwestClient
impl Send for ReqwestClient
impl Sync for ReqwestClient
impl Unpin for ReqwestClient
impl UnsafeUnpin for ReqwestClient
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more