Skip to main content

Config

Struct Config 

Source
pub struct Config {
    pub provider: Arc<dyn CryptoProvider>,
    pub transport: TransportConfig,
    pub reset_key: [u8; 32],
    pub token_key: [u8; 32],
    pub versions: Vec<u32>,
    pub retry: bool,
    pub retry_threshold: usize,
    pub retry_token_lifetime: Duration,
    pub new_token_lifetime: Option<Duration>,
    pub cid_len: usize,
    pub max_connections: usize,
    pub epoch: OnceLock<Instant>,
}
Expand description

Endpoint-wide configuration shared by its connections.

Fields§

§provider: Arc<dyn CryptoProvider>§transport: TransportConfig§reset_key: [u8; 32]

Key for stateless reset tokens (HMAC of the connection ID).

§token_key: [u8; 32]

Key for Retry and NEW_TOKEN address-validation tokens.

§versions: Vec<u32>

Versions accepted by a server, preferred first. A client uses the first.

§retry: bool

Server: always validate addresses with Retry.

§retry_threshold: usize

Server: send Retry once this many connections are in the handshake.

§retry_token_lifetime: Duration

Lifetime of Retry tokens.

§new_token_lifetime: Option<Duration>

Server: issue NEW_TOKEN after the handshake; lifetime of those tokens.

§cid_len: usize

Length of the connection IDs this endpoint issues (4..=20).

§max_connections: usize

Server: most connections kept at once.

§epoch: OnceLock<Instant>

Time base for token ages, set by the first time value the endpoint sees.

Implementations§

Source§

impl Config

Source

pub fn new(provider: Arc<dyn CryptoProvider>) -> Self

A configuration with random keys from the provider and default settings.

Examples found in repository?
examples/bench_quic.rs (line 34)
32fn pair(real: bool) -> (Pair, ConnHandle, ConnHandle) {
33    let (cp, sp) = providers(real);
34    let mut c = Config::new(cp);
35    let mut s = Config::new(sp);
36    for x in [&mut c, &mut s] {
37        x.transport.max_data = 16 << 20;
38        x.transport.stream_window_bidi_local = 8 << 20;
39        x.transport.stream_window_bidi_remote = 8 << 20;
40        x.transport.send_buffer = 8 << 20;
41    }
42    let mut p = Pair::new(Arc::new(c), Arc::new(s), link(), 7);
43    p.batch = 16;
44    let ch = p.connect();
45    assert!(p.run_until(Duration::from_secs(10), |p| p.client.conn(ch).is_some_and(|c| c.is_established())
46        && p.server_conn().and_then(|s| p.server.conn(s)).is_some_and(|c| c.is_established())));
47    let sh = p.server_conn().unwrap();
48    p.run_for(Duration::from_millis(50));
49    (p, ch, sh)
50}
Source

pub fn reset_token(&self, cid: &[u8]) -> [u8; 16]

The stateless reset token for a connection ID (RFC 9000 §10.3.2).

Auto Trait Implementations§

§

impl !Freeze for Config

§

impl !RefUnwindSafe for Config

§

impl !UnwindSafe for Config

§

impl Forget for Config

§

impl Move for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnsafeUnpin for Config

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

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.