Skip to main content

ConnectionIdGenerator

Trait ConnectionIdGenerator 

pub trait ConnectionIdGenerator: Send + Sync {
    // Required methods
    fn generate_cid(&mut self) -> ConnectionId;
    fn cid_len(&self) -> usize;
    fn cid_lifetime(&self) -> Option<Duration>;

    // Provided method
    fn validate(&self, _cid: &ConnectionId) -> Result<(), InvalidCid> { ... }
}
Available on crate feature quic only.
Expand description

Generates connection IDs for incoming connections

Required Methods§

fn generate_cid(&mut self) -> ConnectionId

Generates a new CID

Connection IDs MUST NOT contain any information that can be used by an external observer (that is, one that does not cooperate with the issuer) to correlate them with other connection IDs for the same connection. They MUST have high entropy, e.g. due to encrypted data or cryptographic-grade random data.

fn cid_len(&self) -> usize

Returns the length of a CID for connections created by this generator

fn cid_lifetime(&self) -> Option<Duration>

Returns the lifetime of generated Connection IDs

Connection IDs will be retired after the returned Duration, if any. Assumed to be constant.

Provided Methods§

fn validate(&self, _cid: &ConnectionId) -> Result<(), InvalidCid>

Quickly determine whether cid could have been generated by this generator

False positives are permitted, but increase the cost of handling invalid packets.

Implementors§

§

impl ConnectionIdGenerator for HashedConnectionIdGenerator

§

impl ConnectionIdGenerator for RandomConnectionIdGenerator