-
Notifications
You must be signed in to change notification settings - Fork 516
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
impl Timestamp::{Display, FromStr} with RFC-3339 format #615
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
danburkert
commented
Apr 1, 2022
CC @neoeinstein |
danburkert
commented
Apr 1, 2022
danburkert
commented
Apr 2, 2022
danburkert
commented
Apr 2, 2022
LucioFranco
reviewed
Apr 4, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM mostly one question and also gonna really trust proptest on this one
danburkert
force-pushed
the
prost-types-timestamp
branch
from
April 5, 2022 00:57
91081d3
to
9ea85ff
Compare
@danburkert is this ready for final review? |
Yes, this is ready for final review. Thanks @LucioFranco ! |
danburkert
added a commit
to sisudata/prost
that referenced
this pull request
Apr 7, 2022
This PR implements to and from string methods for `prost_types::Duration` following the duration format defined by the [Protobuf JSON mapping spec][1]. This is a followup to tokio-rs#615 and re-uses a lot of the same parser helpers. [1]: https://developers.google.com/protocol-buffers/docs/proto3#json
LucioFranco
approved these changes
Apr 11, 2022
This PR implements to and from string methods for `prost_types::Timestamp` following the RFC-3339 timestamp format, as also specified by the [Protobuf JSON mapping spec][1]. The `Display` impl always emits the Zulu (Z) timezone, whereas the parser is slightly lenient in accepting fixed timezone offsets, as well as both the `T` and space seperated date and time portions. This leniency in parsing makes it much much more robust to parsing data of less-than-pristine formatting, even though the protobuf spec allows no leniency. Also, since it was easy with the new date time functionality, we've gone ahead and added a trio of convenience construct functions to `Timestamp` which makes it straightforward to create `Timestamp`s out of calendar date time information. This functionality will be used in follow-up PRs to add Serde [de]serialization support to the types in `prost_types`, which is itself a stepping stone towards full JSON support. This PR was extracted from tokio-rs#558, and is based on code which myself and @konradjniemiec have written, and which has been running in production at @sisudata for a few years. The to-string portion of this code has also been incorporated into [`tracing`][2], so it should be pretty well battle hardened. [1]: https://developers.google.com/protocol-buffers/docs/proto3#json [2]: https://github.com/tokio-rs/tracing/blob/master/tracing-subscriber/src/fmt/time/datetime.rs
danburkert
force-pushed
the
prost-types-timestamp
branch
from
April 14, 2022 18:14
a109f14
to
e829806
Compare
danburkert
added a commit
that referenced
this pull request
Apr 14, 2022
This PR implements to and from string methods for `prost_types::Duration` following the duration format defined by the [Protobuf JSON mapping spec][1]. This is a followup to #615 and re-uses a lot of the same parser helpers. Additionally I did the same error type unification with a new `DurationError` type. This is a breaking change for `prost-types` since public APIs are changed slightly. [1]: https://developers.google.com/protocol-buffers/docs/proto3#json
danburkert
added a commit
that referenced
this pull request
Apr 20, 2022
This PR implements to and from string methods for `prost_types::Duration` following the duration format defined by the [Protobuf JSON mapping spec][1]. This is a followup to #615 and re-uses a lot of the same parser helpers. Additionally I did the same error type unification with a new `DurationError` type. This is a breaking change for `prost-types` since public APIs are changed slightly. [1]: https://developers.google.com/protocol-buffers/docs/proto3#json
mdrach
pushed a commit
to sisudata/prost
that referenced
this pull request
Aug 3, 2022
This PR implements to and from string methods for `prost_types::Duration` following the duration format defined by the [Protobuf JSON mapping spec][1]. This is a followup to tokio-rs#615 and re-uses a lot of the same parser helpers. [1]: https://developers.google.com/protocol-buffers/docs/proto3#json
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements to and from string methods for
prost_types::Timestamp
following the RFC-3339 timestamp format, asalso specified by the Protobuf JSON mapping spec. The
Display
impl always emits the Zulu (Z) timezone, whereas the parser is slightly
lenient in accepting fixed timezone offsets, as well as both the
T
andspace seperated date and time portions. This leniency in parsing makes
it much much more robust to parsing data of less-than-pristine
formatting, even though the protobuf spec allows no leniency.
Also, since it was easy with the new date time functionality, we've gone
ahead and added a trio of convenience construct functions to
Timestamp
which makes it straightforward to create
Timestamp
s out of calendardate time information.
This functionality will be used in follow-up PRs to add Serde
[de]serialization support to the types in
prost_types
, which is itselfa stepping stone towards full JSON support.
This PR was extracted from #558, and is based on code which myself and
@konradjniemiec have written, and which has been running in production
at @sisudata for a few years. The to-string portion of this code has
also been incorporated into
tracing
, so it should be pretty wellbattle hardened.