pub struct Client { /* private fields */ }
Expand description
Represents a client for interacting with an API.
The Client
struct contains the necessary configuration for making
requests to an API, including the API token and the timeout duration.
Implementations§
Source§impl Client
impl Client
Sourcepub fn with_timeout(duration: Duration) -> Self
pub fn with_timeout(duration: Duration) -> Self
Creates a new client instance with the specified timeout duration.
This method initializes a new Client
instance with the provided
timeout duration.
§Arguments
timeout
- The timeout duration for requests, in seconds.
Sourcepub fn with_token(token: &str) -> Self
pub fn with_token(token: &str) -> Self
Creates a new client instance with the specified API token.
This method initializes a new Client
instance with the provided
API token and a default timeout duration of 20 seconds.
§Arguments
token
- A string slice that holds the API token.
Sourcepub fn timeout(self, duration: Duration) -> Self
pub fn timeout(self, duration: Duration) -> Self
Sets the timeout duration for the client.
This method allows you to set the timeout duration for the client in seconds. The timeout duration determines how long the client will wait for a response before timing out.
§Arguments
seconds
- The timeout duration in seconds.
Sourcepub fn token(self, token: &str) -> Self
pub fn token(self, token: &str) -> Self
Sets the API token for the client.
This method allows you to set the API token for the client, which will be used for authenticating API requests.
§Arguments
token
- A string slice that holds the API token.