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 to user chose chrono vs time #65

Merged
merged 3 commits into from
Jan 19, 2022
Merged

Conversation

a1ien
Copy link
Contributor

@a1ien a1ien commented Jan 7, 2022

  • I agree to follow the project's code of conduct.
  • I added an entry to CHANGELOG.md if knowledge of this change could be valuable to users.

@lnicola
Copy link
Member

lnicola commented Jan 7, 2022

With features being additive in theory, I'm not too fond of the idea of a Time type that changes depending on what is enabled. But switching from chrono to time seems like a good idea, since the former has been less well maintained lately.

I'd also slightly prefer using the formatting or parsing functions in the tests to avoid pulling in a proc macro.


Let's see what the other reviewers think.

@a1ien
Copy link
Contributor Author

a1ien commented Jan 7, 2022

I add feature because if we switch from chrono to time we must bump version to 0.9. This is because we have chrono in public interface.
So if you ok with switch completely to time I am happy with that.

@a1ien
Copy link
Contributor Author

a1ien commented Jan 7, 2022

Rewrite test without macro

@lnicola
Copy link
Member

lnicola commented Jan 7, 2022

r? @urschrei

@@ -6,6 +6,7 @@ use thiserror::Error;
pub(crate) type GpxResult<T> = Result<T, GpxError>;

#[derive(Error, Debug)]
#[non_exhaustive]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, this is also a breaking change (code that used to match on GpxError will no longer compile).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep.. I don't know what to do with this. Adding to enum also breaking change. If some one match all case

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious why you made this non_exhaustive?

Is it to avoid breaking changes in the future? I could see why that would make sense for a public error type like this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this can avoid breaking changes in the future

@urschrei
Copy link
Member

urschrei commented Jan 7, 2022

One thing to note re: breaking changes is that gpx has no public dependents. I know that doesn't mean it has no dependents, but as a practical consideration, it's likely to affect a small number of users. Sometimes a version bump is the correct thing to do, especially in service of longer-term stability / freedom from security advisories.

@a1ien
Copy link
Contributor Author

a1ien commented Jan 7, 2022

So we can bump to 0.9 and remove chrono?

@michaelkirk
Copy link
Member

michaelkirk commented Jan 7, 2022

Disclaimer: I don't actively use this crate, so this is non-blocking feedback.

It's kind of unfortunate to see so many #cfg checks scattered throughout the code - is there a way we can centralize them? At least the type alias should be easy to centralize.

Though alternatively, would it be better to use our own internal Time type and offer Into/From impls for the time and chrono crates?

@urschrei
Copy link
Member

urschrei commented Jan 7, 2022

So we can bump to 0.9 and remove chrono?

We could; I'm not against it, but as @michaelkirk also noted, I'm not a direct user of the crate. We just maintain it as best we can. Please note that there are some strings attached: if you change and bump, please help us to field questions / do some maintenance if it's required 🙂

Though alternatively, would it be better to use our own internal Time type and offer Into/From impls for the time and chrono crates

If this isn't a huge headache and avoids a breaking change, it's the better option.

@michaelkirk
Copy link
Member

I'm also not against removing chrono support if people think it's reasonable.

Defining an internal type would still be a breaking change here, but might (might) avoid a breaking change in the future when people decide that now the time crate is old-and-busted and we should all be using 2025's latest time keeping crate: "swatch"

I leave it to whoever is doing the work to decide. =)

@lnicola
Copy link
Member

lnicola commented Jan 7, 2022

We could use time for our opaque internal time to avoid reinventing the wheel. But a breaking change every couple of years or so doesn't seem so bad either.

@a1ien
Copy link
Contributor Author

a1ien commented Jan 7, 2022

Rework to internal Time type with From/Into conversion. If we decide to use that approach I can squash commit

@michaelkirk
Copy link
Member

bors try

bors bot added a commit that referenced this pull request Jan 18, 2022
@bors
Copy link
Contributor

bors bot commented Jan 18, 2022

try

Build failed:

Copy link
Member

@michaelkirk michaelkirk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fails without the time feature.

@@ -6,6 +6,7 @@ use thiserror::Error;
pub(crate) type GpxResult<T> = Result<T, GpxError>;

#[derive(Error, Debug)]
#[non_exhaustive]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious why you made this non_exhaustive?

Is it to avoid breaking changes in the future? I could see why that would make sense for a public error type like this.

@a1ien
Copy link
Contributor Author

a1ien commented Jan 19, 2022

Fix optional time crate

@michaelkirk
Copy link
Member

I'm seeing test failures:

$ cargo test --all-features
   Compiling serde_derive v1.0.133                                                     
   Compiling serde v1.0.133          
   Compiling geo-types v0.7.2              
   Compiling time v0.3.5                                                               
   Compiling geo v0.18.0                                                                                                                                                      
   Compiling gpx v0.8.5 (/Users/mkirk/src/georust/gpx)
error[E0277]: the trait bound `parser::time::Time: Serialize` is not satisfied                                                                                                
    --> src/types.rs:83:5                                                                                                                                                     
     |                                                                                                                                                                        
83   |     /// The creation date of the file.                                                                                                                                 
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Serialize` is not implemented for `parser::time::Time`
     |                

Can you verify that you can run the tests?

@a1ien
Copy link
Contributor Author

a1ien commented Jan 19, 2022

Forgot to implement serde derives for time.
Fix.

@michaelkirk
Copy link
Member

bors r+

@bors
Copy link
Contributor

bors bot commented Jan 19, 2022

Merge conflict.

@a1ien
Copy link
Contributor Author

a1ien commented Jan 19, 2022

Fix merge conflict and update changelog

@michaelkirk
Copy link
Member

bors retry

bors bot added a commit that referenced this pull request Jan 19, 2022
65: Allow to user chose chrono vs time r=michaelkirk a=a1ien

- [x] I agree to follow the project's [code of conduct](https://github.com/georust/geo/blob/master/CODE_OF_CONDUCT.md).
- [x] I added an entry to `CHANGELOG.md` if knowledge of this change could be valuable to users.
---



Co-authored-by: Ilya Averyanov <averyanovin@gmail.com>
@bors
Copy link
Contributor

bors bot commented Jan 19, 2022

Build failed:

@michaelkirk
Copy link
Member

Looks like the time crate requires a newer version of rust. I'm ok with updating the minimum supported rust version, but it's nice to know what it is.

Do you know what the minimum supported rust version is after this PR?

@a1ien
Copy link
Contributor Author

a1ien commented Jan 19, 2022

For current version time 0.3.5 MSRV is 1.5.1 for new unreleased it's 1.53

@michaelkirk
Copy link
Member

bors retry

@bors
Copy link
Contributor

bors bot commented Jan 19, 2022

Build succeeded:

@bors bors bot merged commit e86ed78 into georust:master Jan 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants