Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow using clock objects instead of hanging it off the type #31

wants to merge 17 commits into
base: master


None yet
1 participant
Copy link

commented May 31, 2019

This addresses #29:

  • Rework rate-limiting states to take a Clock trait implementation.
  • Tease apart the places where we to I::now() and use that clock object instead.

antifuchs added some commits May 30, 2019

Add clock module
This should eventually supersede the instant module.
Specialize back on Duration
No need to make that generic, and it'll make my job easier folding in
the Clock structure.
Move no_std clock into std, allow it to be used everywhere
Also, rename the with_std clock to live alongside it (as
FakeRelativeClock and FakeAbsoluteClock, respectively)
Define default clock and reference types
These will be used instead of instant::Absolute /
instant::Relative. They'll also let me unify the traits I had to split
up before, since even the no_std fake clock can now operate like an
std one.
Remove the problematic wait_time method on NonConformance
I have to find a way to get the clock passed through to it, otherwise
it's lost forever.
Aaaaand tests pass.
That was ... easy?! I don't know if I'm doing something wrong yet. But
it's working!
Make benchmarks compile again
...but they panic at unwrapping an empty Option. That's not good.
Straighten out the time logic when using no_std Durations
Since the Reference defaults to starting at Duration::new(0, 0), we
can't move back in time to "before" that point, and so all tests need
to update to use some reference after that.

Also, add a reasonable saturating_sub method to the Reference trait,
remove the Sub requirement and use saturating_sub for all our time
maths in algorithms & states.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.