ClientBuilder

Struct ClientBuilder 

Source
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

Source

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
Source

pub fn timeout(self, timeout: Duration) -> Self

Set request timeout

Source

pub fn connect_timeout(self, timeout: Duration) -> Self

Set connection timeout

Source

pub fn retry_config(self, config: RetryConfig) -> Self

Set retry configuration

Source

pub fn retries(self, max_attempts: u32) -> Self

Set number of retry attempts (convenience method)

Source

pub fn logging_config(self, config: LoggingConfig) -> Self

Set logging configuration

Source

pub fn enable_logging(self) -> Self

Enable development logging (convenience method)

Source

pub fn disable_logging(self) -> Self

Disable all logging (convenience method)

Source

pub fn header( self, name: impl AsRef<str>, value: impl AsRef<str>, ) -> Result<Self>

Add custom header

Source

pub fn user_agent(self, user_agent: impl Into<String>) -> Self

Set User-Agent header

Source

pub fn proxy(self, proxy_url: impl Into<String>) -> Self

Set HTTP proxy URL

Source

pub fn pool_config( self, max_idle_per_host: usize, idle_timeout: Duration, ) -> Self

Set connection pool configuration

Source

pub fn gzip(self, enable: bool) -> Self

Enable/disable gzip compression

Source

pub fn brotli(self, enable: bool) -> Self

Enable/disable brotli compression

Source

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

pub fn build(self) -> Result<Client>

Build the configured client

Source§

impl ClientBuilder

Convenience methods for common configurations

Source

pub fn production( base_url: impl Into<String>, license_key: impl Into<String>, ) -> Self

Production configuration with minimal logging and conservative timeouts

Source

pub fn development( base_url: impl Into<String>, license_key: impl Into<String>, ) -> Self

Development configuration with verbose logging and shorter timeouts

Source

pub fn testing( base_url: impl Into<String>, license_key: impl Into<String>, ) -> Self

Testing configuration with no retries and no logging

Trait Implementations§

Source§

impl Debug for ClientBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more