Skip to main content

LimitsBuilder

Struct LimitsBuilder 

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

Builds Limits; every setter is optional.

use net_io::{ConfigReason, Limits, NetError};
let err = Limits::builder().max_connections(100).max_per_listener(200).build().unwrap_err();
assert!(matches!(err, NetError::InvalidConfig { field: "max_per_listener", reason: ConfigReason::AboveGlobal }));
assert!(Limits::builder().max_connections(100).build().is_ok());

Implementations§

Source§

impl LimitsBuilder

Source

pub fn max_connections(self, value: u32) -> Self

The global connection cap.

Source

pub fn max_per_listener(self, value: u32) -> Self

The per-listener connection cap.

Source

pub fn backlog(self, value: u32) -> Self

The listen backlog.

Source

pub fn accept_batch(self, value: u16) -> Self

Connections accepted per wake-up.

Source

pub fn handshake_timeout(self, value: Duration) -> Self

Time for the PROXY header and TLS handshake together.

Source

pub fn idle_timeout(self, value: Duration) -> Self

Time to wait for the next exchange.

Source

pub fn read_timeout(self, value: Duration) -> Self

Time to wait for bytes during an exchange.

Source

pub fn write_timeout(self, value: Duration) -> Self

Time to wait for the peer to take bytes.

Source

pub fn park_timeout(self, value: Duration) -> Self

Time a parked connection may wait for its completion.

Source

pub fn min_rate(self, value: MinRate) -> Self

The minimum transfer rate (MinRate::off to disable).

Source

pub fn output_budget(self, value: u32) -> Self

Pool memory a connection’s output may hold.

Source

pub fn buffer_budget(self, value: u64) -> Self

Total bytes of buffers all workers may allocate.

Source

pub fn drain_timeout(self, value: Duration) -> Self

The drain deadline.

Source

pub fn refusal_bytes_max(self, value: u16) -> Self

The largest refusal reply (at most 512).

Source

pub fn tick(self, value: Duration) -> Self

The timer resolution (1 ms to 100 ms).

Source

pub fn pressure(self, value: Pressure) -> Self

Adaptive deadlines under pressure.

Source

pub fn max_per_source(self, n: u32, policy: PrefixPolicy) -> Self

The per-source concurrency cap and how sources are grouped.

Source

pub fn proxy_header_max(self, v2_body_bytes: u16) -> Self

The PROXY v2 address-and-TLV cap (up to 65,519).

Source

pub fn read_class(self, initial: SizeClass, max: SizeClass) -> Self

The initial read buffer class and the largest a session may grow it to.

Source

pub fn completion_queue(self, n: u32) -> Self

A worker’s completion queue length, rounded up to a power of two.

Source

pub fn graceful_linger(self, time: Duration, bytes: u32) -> Self

The graceful-close linger: time and bytes read and discarded.

Source

pub fn lane_reserve(self, lane: Lane, slots: u32) -> Self

Connection slots reserved for lane (lanes 0 to 7; applied from 0.6.0).

Source

pub fn build(self) -> Result<Limits, NetError>

Checks the values that were set and returns the limits.

§Errors

InvalidConfig { field, reason } for the first rule broken, in the order documented in docs/API.md.

Trait Implementations§

Source§

impl Clone for LimitsBuilder

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 LimitsBuilder

Source§

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

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

impl Default for LimitsBuilder

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