Skip to main content

HttpConfig

Struct HttpConfig 

Source
pub struct HttpConfig {
Show 14 fields pub timeout: Duration, pub connect_timeout: Duration, pub max_retries: u32, pub verbose: bool, pub user_agent: String, pub return_response_headers: bool, pub proxy: Option<ProxyConfig>, pub enable_rate_limit: bool, pub retry_config: Option<RetryConfig>, pub max_response_size: usize, pub max_request_size: usize, pub circuit_breaker: Option<CircuitBreakerConfig>, pub pool_max_idle_per_host: usize, pub pool_idle_timeout: Duration,
}
Expand description

HTTP request configuration

Fields§

§timeout: Duration

Request timeout

§connect_timeout: Duration

TCP connection timeout (default: 10 seconds)

§max_retries: u32
👎Deprecated: Use retry_config instead

Maximum retry attempts (deprecated, use retry_config instead)

§verbose: bool

Whether to enable verbose logging

§user_agent: String

Default User-Agent header value

§return_response_headers: bool

Whether to include response headers in the result

§proxy: Option<ProxyConfig>

Optional proxy configuration

§enable_rate_limit: bool

Whether to enable rate limiting

§retry_config: Option<RetryConfig>

Optional retry configuration (uses default if None)

§max_response_size: usize

Maximum response body size in bytes (default: 10MB)

Responses exceeding this limit will be rejected with an InvalidRequest error. This protects against malicious or abnormal responses that could exhaust memory.

§max_request_size: usize

Maximum request body size in bytes (default: 10MB)

Request bodies exceeding this limit will be rejected BEFORE serialization. This protects against DoS attacks via oversized request payloads.

§circuit_breaker: Option<CircuitBreakerConfig>

Optional circuit breaker configuration.

When enabled, the circuit breaker will track request failures and automatically block requests to failing endpoints, allowing the system to recover.

Default: None (disabled for backward compatibility)

§pool_max_idle_per_host: usize

Maximum number of idle connections per host in the connection pool.

This controls how many keep-alive connections are maintained for each host. Higher values improve performance for repeated requests to the same host but consume more resources.

Default: 10

§pool_idle_timeout: Duration

Timeout for idle connections in the pool.

Connections that have been idle longer than this duration will be closed. This helps free up resources and avoid stale connections.

Default: 90 seconds

Implementations§

Source§

impl HttpConfig

Source

pub fn validate(&self) -> Result<ValidationResult, ConfigValidationError>

Validates the HTTP configuration parameters.

§Returns

Returns Ok(ValidationResult) if the configuration is valid. The ValidationResult may contain warnings for suboptimal but valid configurations.

Returns Err(ConfigValidationError) if the configuration is invalid.

§Validation Rules
  • timeout > 5 minutes returns an error (excessive timeout)
  • timeout < 1 second generates a warning (may cause frequent timeouts)
§Example
use ccxt_core::http_client::HttpConfig;
use std::time::Duration;

let config = HttpConfig::default();
let result = config.validate();
assert!(result.is_ok());

let invalid_config = HttpConfig {
    timeout: Duration::from_secs(600), // 10 minutes - too long
    ..Default::default()
};
let result = invalid_config.validate();
assert!(result.is_err());

Trait Implementations§

Source§

impl Clone for HttpConfig

Source§

fn clone(&self) -> HttpConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for HttpConfig

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for HttpConfig

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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