ConfigBuilder

Struct ConfigBuilder 

Source
pub struct ConfigBuilder { /* private fields */ }
Expand description

Builder for creating Config instances with custom settings.

ConfigBuilder provides a fluent interface for constructing Config objects with specific settings. All methods return self to enable method chaining. Call build() to create the final Config instance.

§Examples

use tlq_client::ConfigBuilder;
use std::time::Duration;

let config = ConfigBuilder::new()
    .host("queue.example.com")
    .port(8080)
    .timeout_ms(5000)          // 5 second timeout
    .max_retries(2)            // Only retry twice
    .retry_delay_ms(250)       // 250ms base delay
    .build();

assert_eq!(config.host, "queue.example.com");
assert_eq!(config.port, 8080);
assert_eq!(config.timeout, Duration::from_millis(5000));

Implementations§

Source§

impl ConfigBuilder

Source

pub fn new() -> Self

Creates a new ConfigBuilder with default settings.

Equivalent to Config::default() but allows method chaining.

§Examples
use tlq_client::ConfigBuilder;

let builder = ConfigBuilder::new();
let config = builder.build();
Source

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

Sets the TLQ server hostname or IP address.

§Arguments
  • host - Any type that can be converted to String
§Examples
use tlq_client::ConfigBuilder;

let config = ConfigBuilder::new()
    .host("queue.example.com")
    .build();
assert_eq!(config.host, "queue.example.com");
Source

pub fn port(self, port: u16) -> Self

Sets the TLQ server port number.

§Arguments
  • port - Port number (1-65535)
§Examples
use tlq_client::ConfigBuilder;

let config = ConfigBuilder::new()
    .port(8080)
    .build();
assert_eq!(config.port, 8080);
Source

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

Sets the request timeout duration.

§Arguments
  • timeout - Maximum time to wait for each request
§Examples
use tlq_client::ConfigBuilder;
use std::time::Duration;

let config = ConfigBuilder::new()
    .timeout(Duration::from_secs(60))
    .build();
assert_eq!(config.timeout, Duration::from_secs(60));
Source

pub fn timeout_ms(self, ms: u64) -> Self

Sets the request timeout in milliseconds.

Convenience method equivalent to timeout(Duration::from_millis(ms)).

§Arguments
  • ms - Timeout in milliseconds
§Examples
use tlq_client::ConfigBuilder;
use std::time::Duration;

let config = ConfigBuilder::new()
    .timeout_ms(5000)  // 5 seconds
    .build();
assert_eq!(config.timeout, Duration::from_millis(5000));
Source

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

Sets the maximum number of retry attempts.

When a retryable error occurs, the client will retry the operation up to this many times before giving up.

§Arguments
  • retries - Maximum retry attempts (0 disables retries)
§Examples
use tlq_client::ConfigBuilder;

let config = ConfigBuilder::new()
    .max_retries(5)
    .build();
assert_eq!(config.max_retries, 5);
Source

pub fn retry_delay(self, delay: Duration) -> Self

Sets the base retry delay duration.

The actual delay between retries uses exponential backoff: delay = base_delay × 2^attempt_number

§Arguments
  • delay - Base delay for exponential backoff
§Examples
use tlq_client::ConfigBuilder;
use std::time::Duration;

let config = ConfigBuilder::new()
    .retry_delay(Duration::from_millis(500))
    .build();
assert_eq!(config.retry_delay, Duration::from_millis(500));
Source

pub fn retry_delay_ms(self, ms: u64) -> Self

Sets the base retry delay in milliseconds.

Convenience method equivalent to retry_delay(Duration::from_millis(ms)).

§Arguments
  • ms - Base delay in milliseconds
§Examples
use tlq_client::ConfigBuilder;
use std::time::Duration;

let config = ConfigBuilder::new()
    .retry_delay_ms(200)  // 200ms base delay
    .build();
assert_eq!(config.retry_delay, Duration::from_millis(200));
Source

pub fn build(self) -> Config

Builds and returns the final Config instance.

Consumes the builder and returns a Config with all the specified settings.

§Examples
use tlq_client::ConfigBuilder;

let config = ConfigBuilder::new()
    .host("localhost")
    .port(1337)
    .max_retries(3)
    .build();
// Use config...

Trait Implementations§

Source§

impl Default for ConfigBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. 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, 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, 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.