Trait s2n_quic::provider::endpoint_limits::Limiter
source · pub trait Limiter: 'static + Send {
// Required method
fn on_connection_attempt(&mut self, info: &ConnectionAttempt<'_>) -> Outcome;
}
Required Methods§
sourcefn on_connection_attempt(&mut self, info: &ConnectionAttempt<'_>) -> Outcome
fn on_connection_attempt(&mut self, info: &ConnectionAttempt<'_>) -> Outcome
This trait is used to determine the outcome of connection attempts on an endpoint. The implementor returns an Outcome based on the ConnectionAttempt, or other information that the implementor may have.
use s2n_quic::provider::endpoint_limits::{Limiter, ConnectionAttempt, Outcome};
struct MyEndpointLimits {
handshake_limit: usize,
delay: core::time::Duration,
}
impl Limiter for MyEndpointLimits {
fn on_connection_attempt(&mut self, info: &ConnectionAttempt) -> Outcome {
if info.inflight_handshakes > self.handshake_limit {
Outcome::retry()
} else {
Outcome::allow()
}
}
}