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
use {Decider, Decision, Limiter, Result}; use std::time::Instant; #[derive(Copy, Clone)] /// The most naive implementation of a rate-limiter ever: Always /// allows every cell through. pub struct Allower {} impl Decider for Allower { /// Allower never returns a negative answer, so negative answers /// don't carry information. type T = (); /// Allows the cell through unconditionally. fn test_and_update(&mut self, _t0: Instant) -> Decision<()> { Decision::Yes } /// Builds the most useless rate-limiter in existence. fn build_with(_l: &Limiter) -> Result<Self> { Ok(Allower {}) } }