pub struct ClientBuilder { /* private fields */ }Expand description
Builds a Client.
Requires either a static token, or both an API key and a secret. Credentials
fall back to the VIDEOSDK_API_KEY and VIDEOSDK_SECRET environment
variables, and the endpoint to VIDEOSDK_API_ENDPOINT.
let client = videosdk::Client::builder()
.api_key("my-key")
.secret("my-secret")
.max_retries(3)
.build()?;Implementations§
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn api_key(self, api_key: impl Into<String>) -> Self
pub fn api_key(self, api_key: impl Into<String>) -> Self
Sets the project API key. Falls back to VIDEOSDK_API_KEY.
Sourcepub fn secret(self, secret: impl Into<String>) -> Self
pub fn secret(self, secret: impl Into<String>) -> Self
Sets the project secret. Falls back to VIDEOSDK_SECRET.
Sourcepub fn base_url(self, base_url: impl Into<String>) -> Self
pub fn base_url(self, base_url: impl Into<String>) -> Self
Sets the API endpoint. Falls back to VIDEOSDK_API_ENDPOINT, then to
DEFAULT_BASE_URL.
Sourcepub fn token(self, token: impl Into<String>) -> Self
pub fn token(self, token: impl Into<String>) -> Self
Uses a pre-generated static token. Disables automatic token refresh unless an API key and secret are also supplied.
Sourcepub fn http_client(self, http_client: Client) -> Self
pub fn http_client(self, http_client: Client) -> Self
Supplies a preconfigured reqwest::Client, e.g. with a proxy or a
custom connection pool.
Sourcepub fn max_retries(self, max_retries: u32) -> Self
pub fn max_retries(self, max_retries: u32) -> Self
Sets how many times a failed request is retried. Defaults to 2, giving up to 3 total attempts.
Sourcepub fn request_timeout(self, timeout: Duration) -> Self
pub fn request_timeout(self, timeout: Duration) -> Self
Sets the per-request timeout. Defaults to 30 seconds; Duration::ZERO
disables it.
This applies to each attempt individually, so a request that exhausts its retries can take longer than this in total.
Sourcepub fn header(self, name: impl Into<String>, value: impl Into<String>) -> Self
pub fn header(self, name: impl Into<String>, value: impl Into<String>) -> Self
Adds a header sent with every request.
Sourcepub fn token_options(self, token_options: TokenOptions) -> Self
pub fn token_options(self, token_options: TokenOptions) -> Self
Overrides the claims of the tokens the client mints for its own requests.