1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//! The shared admission-gate contract: pure `check`/`peek` over caller-held
//! state, returning a [`Decision`]. All rate limiters and the circuit breaker
//! implement [`Gate`].
/// The outcome of an admission decision. `S` is the algorithm's state type;
/// `state` is the state after the operation.
/// An admission gate: a pure decision over caller-held state. Implementors are
/// zero-sized; the caller stores `State` and passes it in each call.
///
/// ```
/// use throttle_machines::gate::{Decision, Gate};
/// use throttle_machines::gcra::{Gcra, GcraParams};
///
/// fn admit<G: Gate>(state: G::State, now: f64, params: G::Params) -> Decision<G::State> {
/// G::check(state, now, params)
/// }
///
/// let params = GcraParams { emission_interval: 0.1, delay_tolerance: 0.0 };
/// assert!(admit::<Gcra>(0.0, 1.0, params).allowed);
/// ```