-
Notifications
You must be signed in to change notification settings - Fork 187
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
Refactor converters to numeric types for aws_smithy_types::Number
#1274
Refactor converters to numeric types for aws_smithy_types::Number
#1274
Commits on Mar 23, 2022
-
Refactor converters to numeric types for
aws_smithy_types::Number
Currently, conversions from `aws_smithy_types::Number` into numeric Rust types (`{i,u}{8, 16, 32, 64}` and `f{32, 64}`) are always lossy, because they use the `as` Rust keyword to cast into the target type. This means that clients and servers are accepting lossy data: for example, if an operation is modeled to take in a 32-bit integer as input, and a client incorrectly sends an integer number that does not fit in 32 bits, the server will silently accept the truncated input. There are malformed request protocol tests that verify that servers must reject these requests. This commit removes the lossy `to_*` methods on `Number` and instead implements `TryFrom<$typ> for Number` for the target numeric type `$typ`. These converters will attempt their best to perform the conversion safely, and fail if it is lossy. The code-generated JSON parsers will now fail with `aws_smithy_json::deserialize::ErrorReason::InvalidNumber` if the number in the JSON document cannot be converted into the modeled integer type without losing precision. For floating point target types, lossy conversions are still performed, via `Number::to_f32_lossy` and `Number::to_f64_lossy`.
Configuration menu - View commit details
-
Copy full SHA for 03b51a0 - Browse repository at this point
Copy the full SHA 03b51a0View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7cace8a - Browse repository at this point
Copy the full SHA 7cace8aView commit details -
Configuration menu - View commit details
-
Copy full SHA for ab6f306 - Browse repository at this point
Copy the full SHA ab6f306View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6130fcb - Browse repository at this point
Copy the full SHA 6130fcbView commit details
Commits on Apr 11, 2022
-
Configuration menu - View commit details
-
Copy full SHA for fc23fad - Browse repository at this point
Copy the full SHA fc23fadView commit details -
Merge remote-tracking branch 'awslabs/main' into davidpz-refactor-con…
…verters-to-numeric-types
Configuration menu - View commit details
-
Copy full SHA for ae129ec - Browse repository at this point
Copy the full SHA ae129ecView commit details -
Configuration menu - View commit details
-
Copy full SHA for c21572d - Browse repository at this point
Copy the full SHA c21572dView commit details
Commits on Jul 19, 2022
-
Configuration menu - View commit details
-
Copy full SHA for 8aba8cd - Browse repository at this point
Copy the full SHA 8aba8cdView commit details
Commits on Aug 12, 2022
-
Configuration menu - View commit details
-
Copy full SHA for e17da69 - Browse repository at this point
Copy the full SHA e17da69View commit details -
Merge remote-tracking branch 'upstream/main' into davidpz-refactor-co…
…nverters-to-numeric-types
Configuration menu - View commit details
-
Copy full SHA for 1f383c7 - Browse repository at this point
Copy the full SHA 1f383c7View commit details -
Configuration menu - View commit details
-
Copy full SHA for afffb9c - Browse repository at this point
Copy the full SHA afffb9cView commit details -
Merge remote-tracking branch 'upstream/main' into davidpz-refactor-co…
…nverters-to-numeric-types
Configuration menu - View commit details
-
Copy full SHA for a67cb97 - Browse repository at this point
Copy the full SHA a67cb97View commit details
Commits on Aug 16, 2022
-
Configuration menu - View commit details
-
Copy full SHA for 329a929 - Browse repository at this point
Copy the full SHA 329a929View commit details -
Configuration menu - View commit details
-
Copy full SHA for c0400f6 - Browse repository at this point
Copy the full SHA c0400f6View commit details -
Merge remote-tracking branch 'upstream/main' into davidpz-refactor-co…
…nverters-to-numeric-types
Configuration menu - View commit details
-
Copy full SHA for 9b7fb96 - Browse repository at this point
Copy the full SHA 9b7fb96View commit details
Commits on Aug 19, 2022
-
Merge remote-tracking branch 'upstream/main' into davidpz-refactor-co…
…nverters-to-numeric-types
Configuration menu - View commit details
-
Copy full SHA for 752d632 - Browse repository at this point
Copy the full SHA 752d632View commit details