pub struct ClientBuilder { /* private fields */ }Expand description
Builder for configuring Truthlinked API client
Provides a fluent interface for configuring all client options including timeouts, retries, logging, custom headers, and security settings.
§Example
use truthlinked_sdk::ClientBuilder;
use std::time::Duration;
let client = ClientBuilder::new("https://api.truthlinked.org", "tl_free_...")
.timeout(Duration::from_secs(60))
.retries(5)
.user_agent("MyApp/1.0")
.header("X-Request-ID", "12345")?
.enable_logging()
.build()?;Implementations§
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn new(base_url: impl Into<String>, license_key: impl Into<String>) -> Self
pub fn new(base_url: impl Into<String>, license_key: impl Into<String>) -> Self
Create a new client builder
§Arguments
base_url- API base URL (must be HTTPS)license_key- Your Truthlinked license key
Sourcepub fn connect_timeout(self, timeout: Duration) -> Self
pub fn connect_timeout(self, timeout: Duration) -> Self
Set connection timeout
Sourcepub fn retry_config(self, config: RetryConfig) -> Self
pub fn retry_config(self, config: RetryConfig) -> Self
Set retry configuration
Sourcepub fn retries(self, max_attempts: u32) -> Self
pub fn retries(self, max_attempts: u32) -> Self
Set number of retry attempts (convenience method)
Sourcepub fn logging_config(self, config: LoggingConfig) -> Self
pub fn logging_config(self, config: LoggingConfig) -> Self
Set logging configuration
Sourcepub fn enable_logging(self) -> Self
pub fn enable_logging(self) -> Self
Enable development logging (convenience method)
Sourcepub fn disable_logging(self) -> Self
pub fn disable_logging(self) -> Self
Disable all logging (convenience method)
Sourcepub fn header(
self,
name: impl AsRef<str>,
value: impl AsRef<str>,
) -> Result<Self>
pub fn header( self, name: impl AsRef<str>, value: impl AsRef<str>, ) -> Result<Self>
Add custom header
Sourcepub fn user_agent(self, user_agent: impl Into<String>) -> Self
pub fn user_agent(self, user_agent: impl Into<String>) -> Self
Set User-Agent header
Sourcepub fn pool_config(
self,
max_idle_per_host: usize,
idle_timeout: Duration,
) -> Self
pub fn pool_config( self, max_idle_per_host: usize, idle_timeout: Duration, ) -> Self
Set connection pool configuration
Sourcepub fn certificate_pin(self, pin: impl Into<String>) -> Self
pub fn certificate_pin(self, pin: impl Into<String>) -> Self
Add certificate pin for enhanced security
§Arguments
pin- SHA256 hash of the certificate’s public key (base64 encoded)
Source§impl ClientBuilder
Convenience methods for common configurations
impl ClientBuilder
Convenience methods for common configurations
Sourcepub fn production(
base_url: impl Into<String>,
license_key: impl Into<String>,
) -> Self
pub fn production( base_url: impl Into<String>, license_key: impl Into<String>, ) -> Self
Production configuration with minimal logging and conservative timeouts
Trait Implementations§
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