-
-
Notifications
You must be signed in to change notification settings - Fork 281
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
Generic serialize/deserialize for well-known types #581
Conversation
- Allows serde::timestamp to be used for more common types without additional modules. - Added serde::timestamp::millis for the cases where greater time fidelity is needed in a standardised way (javascript natively expects timestamps to be in milliseconds) - Included tests for the above - Deprecated the timestamp::option module as this achieves the same effect seamlessly - Maybe expanding this concept to other well-known serde types?
- Replaces intermediate structs - Allows for generic serialising/deserialising from a single function - Currently implemented for: - Timestamp/TimestampMillis - T,Option<T>,Vec<T>,[T] (ser only)
Codecov Report
@@ Coverage Diff @@
## main #581 +/- ##
=======================================
- Coverage 95.7% 95.5% -0.3%
=======================================
Files 79 79
Lines 8795 8906 +111
=======================================
+ Hits 8421 8504 +83
- Misses 374 402 +28
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Is there any interest in this method for handling serde in a nice way? I'm happy to progress this to handle all serde implementations, but if it's not the path to go down I'd rather not spend the time. |
Looking strictly at the public API (via generated rustdoc), I have some questions and concerns.
|
Thanks for the review! |
For how to limit the ability to access something: mod private {
pub struct Timestamp;
pub trait AsWellKnown {}
}
use private::Timestamp;
use private::AsWellKnown; So long as there's never a |
Would you mind providing an update? |
b963f68
to
b1735de
Compare
c8bc729
to
8060100
Compare
Closing as inactive. |
This pull request allows a user of the time crate to seamlessly use a single well-known serde module with various types, without needing to change the end module that it is pointing at. This is both easier for users, easy to add future impls to support more container types, and easy to add support for more well-known types for all available container types.
Not finished implementation yet, but the current state is:
Should fix #452
Example of use: