s2n_quic/provider/
limits.rs

1// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2// SPDX-License-Identifier: Apache-2.0
3
4//! Provides limits support for a connection
5
6pub use s2n_quic_core::connection::limits::{
7    ConnectionInfo, HandshakeInfo, Limiter, Limits, UpdatableLimits,
8};
9
10pub trait Provider {
11    type Limits: 'static + Send + Limiter;
12    type Error: 'static + core::fmt::Display + Send + Sync;
13
14    fn start(self) -> Result<Self::Limits, Self::Error>;
15}
16
17pub use default::Provider as Default;
18
19impl_provider_utils!();
20
21impl<T: 'static + Send + Limiter> Provider for T {
22    type Limits = T;
23    type Error = core::convert::Infallible;
24
25    fn start(self) -> Result<Self::Limits, Self::Error> {
26        Ok(self)
27    }
28}
29
30pub mod default {
31    #[derive(Debug, Default)]
32    pub struct Provider(());
33
34    impl super::Provider for Provider {
35        type Limits = super::Limits;
36        type Error = core::convert::Infallible;
37
38        fn start(self) -> Result<Self::Limits, Self::Error> {
39            Ok(Self::Limits::default())
40        }
41    }
42}