-
Notifications
You must be signed in to change notification settings - Fork 180
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
Relegate chrono
to an optional feature in a new conversion crate
#849
Conversation
Rename methods on Instant to have a consistent naming scheme. Remove built-in Instant conversions.
A new generated diff is ready to view: __generated-main...__generated-jdisanti-replace-chrono |
1 similar comment
A new generated diff is ready to view: __generated-main...__generated-jdisanti-replace-chrono |
Looks like I need to revisit |
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! Notes are all extremely minor, this looks great.
...tlin/software/amazon/smithy/rust/codegen/smithy/customizations/SmithyTypesPubUseGenerator.kt
Show resolved
Hide resolved
pub enum Error { | ||
/// Conversion failed because the value being converted is out of range for its destination | ||
#[non_exhaustive] | ||
OutOfRange(Box<dyn StdError + Send + Sync + 'static>), |
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.
is this error type actually unknown? I figured it would always be DateTimeParseError
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.
I made this one open ended so that we can add additional library conversions to the aws-smithy-types-convert
crate without having to change the error type at all. In this case, the only error being fed into Error::OutOfRange
is the error from time::OffsetDateTime::from_unix_timestamp_nanos
.
aws/SDK_CHANGELOG.md
Outdated
@@ -1,6 +1,56 @@ | |||
vNext (Month Day, Year) | |||
======================= | |||
|
|||
**Breaking Changes** | |||
|
|||
Several breaking changes around `aws_smithy_types::Instant` were introduced by smithy-rs#TODO: |
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.
can you:
- list out the crates with breaking changes as a top level item (for ease of release cutting)
- add the changes to aws-sigv4 and aws-sig-auth
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.
list out the crates with breaking changes as a top level item (for ease of release cutting)
I'm not sure I understand how this makes releasing eaiser.
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.
Added a changelog entry for aws-sigv4
. There weren't any breaking changes to aws-sig-auth
.
A new generated diff is ready to view: __generated-main...__generated-jdisanti-replace-chrono |
1 similar comment
A new generated diff is ready to view: __generated-main...__generated-jdisanti-replace-chrono |
b427b2e
to
c4d82a5
Compare
A new generated diff is ready to view: __generated-main...__generated-jdisanti-replace-chrono |
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. Nice change!
Some of the examples in the Tier2 CI need to be updated:
|
use std::error::Error as StdError; | ||
use std::fmt; | ||
|
||
/// Conversion erro/Insta |
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.
Unfinished comment.
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.
Good catch! Thanks.
} | ||
|
||
/// Adds functions to [`DateTime`] to convert it to `time` or `chrono` types. | ||
/// |
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.
/// |
doc = r##" | ||
# Example with `time` | ||
|
||
Make sure your *Cargo.toml* enables the `convert-time` feature: |
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.
Make sure your *Cargo.toml* enables the `convert-time` feature: | |
Make sure your `Cargo.toml` enables the `convert-time` feature: |
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.
note that the suggested change is missing a space after your
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.
This raises the question of what our API doc style is. Our AWS SDK Guide Documentation uses bold for file names, and I'm inclined to be consistent with that. Open to debate though.
doc = r##" | ||
# Example with `chrono` | ||
|
||
Make sure your *Cargo.toml* enables the `convert-chrono` feature: |
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.
Make sure your *Cargo.toml* enables the `convert-chrono` feature: | |
Make sure your `Cargo.toml` enables the `convert-chrono` feature: |
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
|
||
//! DateTime value for representing Smithy timestamps. |
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.
//! DateTime value for representing Smithy timestamps. | |
//! DateTime type for representing Smithy timestamps. |
const NANOS_PER_SECOND: i128 = 1_000_000_000; | ||
const NANOS_PER_SECOND_U32: u32 = 1_000_000_000; | ||
|
||
/* ANCHOR: date_time */ |
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.
What are these "anchors" about?
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.
when we generate the mdbook of smithy docs, these code snippets get included
// This code is taken from https://github.com/pyfisch/httpdate and modified under an | ||
// Apache 2.0 License. Modifications: | ||
// - Removed use of unsafe | ||
// - Add serialization and deserialization of subsecond nanos |
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.
My first reaction upon seeing this code was "why aren't we using httpdate
"? These strike me as valuable additions to contribute upstream. Can we? Also, can't we simply depend on httpdate
and wrap it in a newtype to provide our additional functionality?
Also, I'm not a lawyer, but I thought that if one copied MIT-licensed code, a copy of the MIT license has to be included with it.
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.
// - Add serialization and deserialization of subsecond nanos
this is outside of the HTTP date spec (as in, "wrong" if you're actually parsing and serializing http dates.
A new generated diff is ready to view: __generated-main...__generated-jdisanti-replace-chrono |
A new generated diff is ready to view: __generated-main...__generated-jdisanti-replace-chrono |
Motivation and Context
This PR removes the
aws-smithy-types
andaws-sigv4
dependency onchrono
for date-time parsing/formatting since it is no longer maintained and has a CVE.Description
aws-smithy-types
andaws-sigv4
were refactored to use thetime
crate rather thanchrono
.Instant
was renamed toDateTime
to avoid confusion with the standard library type.DateTime
formatting now returns a result instead of panicking when theDateTime
can't be represented in the requested format.DateTime
is now re-exported from service crates so that an explicit dependency onaws-smithy-types
isn't required anymore.chrono
conversions were retained in a newaws-smithy-types-convert
crate behind an optional feature. Conversions to thetime
crate were also added.Testing
Checklist
CHANGELOG.md
aws/SDK_CHANGELOG.md
if applicableBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.