-
-
Notifications
You must be signed in to change notification settings - Fork 118
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
chrono
feature to allow library users to either use time
or chrono
dependency
#213
Conversation
The `time` feature (default) represents the library’s previous behavior, providing date & time functionality using the [`time` crate][time_cio]. Gating it behind a feature lets users opt out of that, and instead opt into using the [`chrono` crate][chrono_cio]. [time_cio]: https://crates.io/crates/time [chrono_cio]: https://crates.io/crates/chrono
This simply gates all date & time functionality behind either of those features, plus some functionality that relies on date & time functionality, such as “removal“ cookies.
There's no way this can work. The features need to be truly additive - there is no exception for crates that are used as transitive dependencies. Imagine a crate Foo that depends on crates A and B where A depends on Cookie with chrono and B depends on cookie with time. Foo will fail to compile, and there's no recourse. The only way to add support for chrono and/or time is to create independent I'm not sure if a |
Understood and agreed. I could try and see if I can make your suggestion work. However, if we’re already going the way of independent †As long as we have it handy we can and should use one of those crates for formatting as well, but we wouldn’t strictly need the crate, since |
I agree, though I still think we need to provide conversion impls and pick a crate, any crate (could even be In short:
|
For what it's worth, I did offer to have a shared |
It's not just |
Closing in favor of moving forward with #217. |
The
chrono
feature brings in thechrono
crate as a dependency & uses it to reimplement all date & time functionality. In essence, it useschrono::DateTime
<
chrono::FixedOffset
>
inExpiration::DateTime
rather thantime::OffsetDateTime
(FixedOffset
seems to best matchOffsetDateTime
’soffset
field), andchrono::Duration
rather thantime::Duration
.The
time
feature (which becomes a default feature) represents the library’s previous behavior, implementing date & time functionality using thetime
crate. Gating it behind a feature lets users opt out of using that crate, and into using thechrono
crate instead.In order to let the library continue working with
default-features = false
, all date & time functionality is gated behind either of these features. So too is some other functionality that relies on date & time functionality, such as “removal“ cookies. In order to avoid adding a lot of noise to doctests those too are gated behind thetime
feature.This is a breaking change, given that it effectively removes all date & time functionality when neither feature is enabled, e.g. when
default-features = false
. Given that thecookies
crate did not previously have default features, it seems plausible that few were actually disabling those. Whentime
is enabled (which in many cases it will be as a default feature), none of the changes are breaking.All regular tests pass, but I have not had the opportunity to run the fuzzers yet.
I went ahead an implemented this as I understood that it might be welcome from a comment by @SergioBenitez in #109. In another comment, @jhpratt express concern that the features wouldn’t be additive, but IIUC strictly either feature on its own is additive — they’re just mutually exclusive, for which the Cargo Book carves out an exception.
On a final note, also discussed in #109, removing the use of
time::Duration
(orchrono::Duration
for that matter) in favor ofstd::time::Duration
would clean this PR up a bit: themax_age
stuff wouldn’t need to be feature-gated.