pub struct Client { /* private fields */ }Expand description
Typed HTTP client built on reqwest.
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(base_url: impl AsRef<str>) -> Result<Self>
pub fn new(base_url: impl AsRef<str>) -> Result<Self>
Creates a client with default reqwest settings and the given base URL.
§Examples
let client = Client::new("https://api.example.com")?;
let _ = client.get("/health").send().await?;Sourcepub fn builder() -> ClientBuilder
pub fn builder() -> ClientBuilder
Returns a ClientBuilder for advanced configuration.
Sourcepub fn with_http_client(
reqwest_client: ReqwestClient,
base_url: impl AsRef<str>,
) -> Result<Self>
pub fn with_http_client( reqwest_client: ReqwestClient, base_url: impl AsRef<str>, ) -> Result<Self>
Builds a client with a custom reqwest instance. ClientBuilder::base_url is required.
Sourcepub fn call<E: Endpoint>(&self) -> EndpointRequestBuilder<'_, E>
pub fn call<E: Endpoint>(&self) -> EndpointRequestBuilder<'_, E>
Sourcepub fn config(&self) -> &ClientConfig
pub fn config(&self) -> &ClientConfig
Returns a snapshot of this client’s configuration.
Sourcepub fn get(&self, path: impl Into<String>) -> RequestBuilder<'_>
pub fn get(&self, path: impl Into<String>) -> RequestBuilder<'_>
Starts a GET request for path (supports :param templates).
Sourcepub fn post(&self, path: impl Into<String>) -> RequestBuilder<'_>
pub fn post(&self, path: impl Into<String>) -> RequestBuilder<'_>
Starts a POST request for path.
Sourcepub fn put(&self, path: impl Into<String>) -> RequestBuilder<'_>
pub fn put(&self, path: impl Into<String>) -> RequestBuilder<'_>
Starts a PUT request for path.
Sourcepub fn patch(&self, path: impl Into<String>) -> RequestBuilder<'_>
pub fn patch(&self, path: impl Into<String>) -> RequestBuilder<'_>
Starts a PATCH request for path.
Sourcepub fn delete(&self, path: impl Into<String>) -> RequestBuilder<'_>
pub fn delete(&self, path: impl Into<String>) -> RequestBuilder<'_>
Starts a DELETE request for path.
Sourcepub fn head(&self, path: impl Into<String>) -> RequestBuilder<'_>
pub fn head(&self, path: impl Into<String>) -> RequestBuilder<'_>
Starts a HEAD request for path.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnsafeUnpin for Client
impl !UnwindSafe 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