Description
I was trying to use this crate to implement rate limiting in a synchronous context, and using the default direct rate limiter, where a negative decision hands back NotUntil<P>
so the caller can interrogate when a conforming decision is likely to be able to be made.
OK, cool... and there's NotUntil::earliest_possible
and NotUntil::wait_time_from
, but as it turns out, they're useless from outside of RateLimiter
itself unless you also manage a clock yourself. NotUntil::earliest_possible
gives you a quasi-Instant
which needs another quasi-Instant
from which to derive a Duration
of how long to wait, and likewise, NotUntil::wait_time_from
needs the same thing. RateLimiter
does this by just calling self.clock.now()
to get that from
parameter required for NotUntil::wait_time_from
... but there's no way to actually access the clock being used by RateLimiter
.
Thus, in the end, you have to manage your own clock and keep it side-by-side with RateLimiter
just to do anything in a synchronous context, which seems like a big ergonomics pitfall.