-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
add ecosystem integration to jiff? (e.g., optional dependencies on icu
, diesel
, sqlx
, etc)
#50
Comments
Can you make those integrations a separate crate? |
Not easily. Or at least, not without a degraded user experience. Because of the orphan rule. That is, I expect most "integrations" to be implementing traits for Jiff data types. That means the integration needs to be:
|
for (3) maybe a nice macro could minimize the friction this will make dependency-conscious ppl more likely to integrate jiff |
I don't think One of these days, I hope we figure out a way to relax the orphan rule enough that a Ideally, some of the crates will be willing to accept PRs early on, in the hopes that they'll treat a new low-level data type crate favorably. If they don't want to integrate it because it's pre-1.0, you might be able to get confirmation that they'd be willing to integrate it once it's 1.0. If that doesn't work, then for something like |
I like that plan @joshtriplett. I think that's probably best way to go. I think this will be my next focus, because I feel like I hear "jiff doesn't have as much ecosystem integration" as a big friction point. The newtype approach when an integration point downstream is perhaps not yet desirable does seem better than doing it directly from Jiff. Definitely not ideal, but I think there is enough "meat and potatoes" when converting between datetime types that it is actually worth doing. |
Hi, If you finished the postgres support for jiff, can you please do the same for DuckDB? It has exactly the same data types as postgres, so I hope it should be trivial. The relevant crate is Thank you very much! I am growing my Rust usage and slowly shedding the chrono dependency. Tony |
I haven't done anything yet. I'll likely prioritize the crates that folks use the most first. But I'll keep |
Here is a snippet I used in my private project that proves this way works - launchbadge/sqlx#3487 (comment) (wrap Timestamp to bridge from/to PG's TIMESTAMPTZ) I'm not quite familiar with the wrapper way. If one can provide a code snippet of how we can implement "2) bidirectional From impls, 3) a Deref impl" in a decent way, I may be able to spend some time trying out a sqlx-jiff crate. It will define feature flags like "postgres", "mysql" and "sqlite" for different backends. Note that some sqlx integration like |
I think I would prefer having the integration crates live in this repository. Some of the integrations (like PostgreSQL, as you've discovered) are pretty subtle, and I think it's important to have them under the umbrella of either the Jiff project or the project that's being integrated with. I don't have a ton of time unfortunately to do abstract mentoring. With that said, if you want to get started by submitting a PR to this repo with a new |
In #4 and in other places, I've resisted adding "ecosystem integration" into Jiff. Not necessarily because I expected others to instead depend on Jiff necessarily right away, but that eventually, as folks started using Jiff (hopefully), it would make sense for them to add a Jiff option.
But I think I should probably flip this script. Getting Jiff adopted is going to be difficult, and I don't know if it has any broadly applicable "killer feature" that will convince folks to jump over from other datetime libraries. (I think Jiff's
Span
is really amazing, but I haven't figured out the best way of communicating that to a broad audience yet.) I think this means that the best path to Jiff adoption is to reduce friction as much as possible.I get the sense that folks rely heavily on other crates providing integration points for their chosen datetime types of choice. In particular, it is often the case that converting from one type to another is actually quite tricky. Even tricky enough that I myself get tripped up. So expecting users to just hand-roll these sorts of integrations is probably pretty lofty.
So... I think one way to reduce friction is for Jiff to provide these integrations. One of my initial reservations was introducing public dependencies on crates that are "less stable/mature." While Jiff is currently brand new and I expect to do some breaking change releases, I do hope that in about ~1 year's time, we'll have a Jiff 1.0 and that I'll commit to that for the foreseeable future with no breaking changes. However, I actually don't think this is a huge deal. We can just include the major/minor version of the crate in the feature name itself, just like
rust-postgres
does.I have two concerns with this approach. That is, if I start this way by introducing dependencies on crates like
diesel
, then:diesel
(diesel
is just an example, this applies to most crates I think), then what happens if those bigger systems actually need to depend on a datetime library? Recursive dependencies are a no-go.Should I pursue this course? Should I limit it to Jiff 0.x versions and then, once 1.0 is out, insist that the integration points get flipped? I'm not sure. That will make 3 datetime choices for a lot of crates, and it's a tough sell.
The text was updated successfully, but these errors were encountered: