pub struct ClientBuilder { /* private fields */ }
Expand description
A builder for creating an instance of Client
.
This builder allows for configuring optional parameters for Client
,
such as a custom API URL or a custom Reqwest client.
§Examples
use ddclient_rs::{Client, ClientBuilder};
let client = Client::builder("my-api-key".to_string())
.api_url("https://custom-api.directdecisions.com".to_string())
.build();
Implementations§
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn api_url(self, api_url: String) -> Self
pub fn api_url(self, api_url: String) -> Self
Sets a custom API URL for the Client
.
If not set, a default URL is used.
§Arguments
api_url
- A string representing the custom API URL.
Sourcepub fn reqwest_client(self, client: Client) -> Self
pub fn reqwest_client(self, client: Client) -> Self
Sets a custom Reqwest client for the Client
.
If not set, a default Reqwest client is used.
§Arguments
client
- An instance ofreqwest::Client
to be used with theClient
.
Sourcepub fn build(self) -> Client
pub fn build(self) -> Client
Builds and returns a new Client
instance.
This method consumes the builder, applies URL validation and formatting,
and uses the provided configurations to create a Client
.
If certain configurations are not provided, default values are used.
§Panics
Panics if the provided API URL is invalid.
§Returns
Returns a Client
instance with the configured options.
§Examples
use ddclient_rs::Client;
let client = Client::builder("my-api-key".to_string())
.api_url("https://custom-api.directdecisions.com".to_string())
.build();
Auto Trait Implementations§
impl Freeze for ClientBuilder
impl !RefUnwindSafe for ClientBuilder
impl Send for ClientBuilder
impl Sync for ClientBuilder
impl Unpin for ClientBuilder
impl !UnwindSafe for ClientBuilder
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