Skip to main content

Limits

Struct Limits 

Source
pub struct Limits {
    pub max_connections: Option<usize>,
    pub max_connections_per_host: Option<usize>,
    pub max_in_flight_requests: Option<usize>,
    pub max_in_flight_requests_per_origin: Option<usize>,
    pub max_idle_connections: Option<usize>,
    pub max_idle_connections_per_host: Option<usize>,
    pub keepalive_expiry: Option<Duration>,
}
Expand description

Resource limits for the connection pool.

Distinguishes between logical request concurrency (pool permits, one per in-flight request) and physical connection behavior (Hyper’s internal idle pool).

§Logical vs physical

  • max_in_flight_requests / max_in_flight_requests_per_origin bound logical requests. Under H1 one request usually owns its connection slot; under H2/H3 many requests multiplex over one connection/QUIC session while each still holds a permit.
  • max_idle_connections* / keepalive_expiry are physical idle-pool policy passed to Hyper, not concurrency bounds.

max_connections / max_connections_per_host are compatibility aliases for the pre-1.0 line (same semantics as the new names; the HTTPX facade keeps Limits(max_connections=...) unchanged). When both alias and new name are set, the new name wins.

Fields§

§max_connections: Option<usize>

Maximum concurrent logical requests (pool permits).

Compatibility alias for max_in_flight_requests. Maps to pool max_connections.

§max_connections_per_host: Option<usize>

Maximum concurrent logical requests per origin.

Compatibility alias for max_in_flight_requests_per_origin. Maps to pool max_connections_per_host.

§max_in_flight_requests: Option<usize>

Maximum concurrent in-flight requests (logical, preferred name).

One permit per request, not one TCP connection. H1/H2/H3 examples: H1 serializes one request per connection; H2 multiplexes many streams over one TCP connection up to the server’s SETTINGS_MAX_CONCURRENT_STREAMS; H3 multiplexes over QUIC with bidi streams derived from the per-origin limit.

§max_in_flight_requests_per_origin: Option<usize>

Maximum concurrent in-flight requests per origin (logical, preferred name).

§max_idle_connections: Option<usize>

Maximum number of idle (kept-alive) connections. Maps to hyper’s pool idle connection limit (physical).

§max_idle_connections_per_host: Option<usize>

Maximum number of idle connections per host (physical). Maps to hyper’s pool per-host idle limit.

Together with Self::max_idle_connections this resolves to one effective per-host cap (max_idle_connections_per_host.or(max_idle_connections)) shared by every persistent Hyper client family.

§keepalive_expiry: Option<Duration>

Duration after which idle connections are closed (physical).

When set, every persistent Hyper client also receives the pool timer Hyper requires for background idle eviction.

Implementations§

Source§

impl Limits

Source

pub fn effective_max_in_flight(&self) -> Option<usize>

Effective global logical-request limit (new name wins).

Source

pub fn effective_max_in_flight_per_origin(&self) -> Option<usize>

Effective per-origin logical-request limit (new name wins).

Source§

impl Limits

Source

pub fn compat() -> Self

Create HTTPX-compatible limits.

HTTPX 0.28.1 defaults to 100 total connections with a 5-second keepalive expiry. Per-host idle connections default to 20. No per-host concurrency limit is set.

§Examples
use eggfetch_core::Limits;

let limits = Limits::compat();
assert_eq!(limits.max_connections, Some(100));
assert!(limits.max_connections_per_host.is_none());
assert_eq!(limits.max_idle_connections, Some(20));
assert_eq!(limits.max_idle_connections_per_host, Some(20));
assert_eq!(limits.keepalive_expiry, Some(std::time::Duration::from_secs(5)));
Source

pub fn native() -> Self

Create unlimited defaults (all None).

No concurrency limits or idle connection caps are applied. Idle connections are never proactively closed.

§Examples
use eggfetch_core::Limits;

let limits = Limits::native();
assert!(limits.max_connections.is_none());
assert!(limits.max_connections_per_host.is_none());
assert!(limits.max_idle_connections.is_none());
assert!(limits.max_idle_connections_per_host.is_none());
assert!(limits.keepalive_expiry.is_none());

Trait Implementations§

Source§

impl Clone for Limits

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Limits

Source§

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

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

impl Default for Limits

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<Limits> for PoolConfig

Source§

fn from(limits: Limits) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Limits

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Limits

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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<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