From 84c36e7ffa6d2c388d47e7551cffa9ca7f6487a9 Mon Sep 17 00:00:00 2001 From: Andreas Fuchs Date: Mon, 10 Jun 2024 09:01:16 -0400 Subject: [PATCH] stream.rs: Eliminate the redundant Clock+ReasonablyRealtime bounds They indicated the same thing and resulted in weird-to-read type signatures, and only in the StreamRateLimitExt trait, too: Drop the Clock bound, and only use ReasonablyRealtime. --- governor/src/state/direct/streams.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/governor/src/state/direct/streams.rs b/governor/src/state/direct/streams.rs index 0fdb6045..6705a385 100755 --- a/governor/src/state/direct/streams.rs +++ b/governor/src/state/direct/streams.rs @@ -24,15 +24,14 @@ pub trait StreamRateLimitExt<'a>: Stream { /// it will not `poll` the underlying stream. fn ratelimit_stream< D: DirectStateStore, - C: clock::Clock, + C: clock::ReasonablyRealtime, MW: RateLimitingMiddleware, >( self, limiter: &'a RateLimiter, ) -> RatelimitedStream<'a, Self, D, C, MW> where - Self: Sized, - C: clock::ReasonablyRealtime; + Self: Sized; /// Limits the rate at which the stream produces items, with a randomized wait period. /// @@ -43,7 +42,7 @@ pub trait StreamRateLimitExt<'a>: Stream { /// it will not `poll` the underlying stream. fn ratelimit_stream_with_jitter< D: DirectStateStore, - C: clock::Clock, + C: clock::ReasonablyRealtime, MW: RateLimitingMiddleware, >( self, @@ -51,14 +50,13 @@ pub trait StreamRateLimitExt<'a>: Stream { jitter: Jitter, ) -> RatelimitedStream<'a, Self, D, C, MW> where - Self: Sized, - C: clock::ReasonablyRealtime; + Self: Sized; } impl<'a, S: Stream> StreamRateLimitExt<'a> for S { fn ratelimit_stream< D: DirectStateStore, - C: clock::Clock, + C: clock::ReasonablyRealtime, MW: RateLimitingMiddleware, >( self, @@ -66,14 +64,13 @@ impl<'a, S: Stream> StreamRateLimitExt<'a> for S { ) -> RatelimitedStream<'a, Self, D, C, MW> where Self: Sized, - C: clock::ReasonablyRealtime, { self.ratelimit_stream_with_jitter(limiter, Jitter::NONE) } fn ratelimit_stream_with_jitter< D: DirectStateStore, - C: clock::Clock, + C: clock::ReasonablyRealtime, MW: RateLimitingMiddleware, >( self, @@ -82,7 +79,6 @@ impl<'a, S: Stream> StreamRateLimitExt<'a> for S { ) -> RatelimitedStream<'a, Self, D, C, MW> where Self: Sized, - C: clock::ReasonablyRealtime, { RatelimitedStream { inner: self,