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

Refactor converters to numeric types for aws_smithy_types::Number #1274

Merged
merged 16 commits into from
Aug 19, 2022

Commits on Mar 23, 2022

  1. 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`.
    david-perez committed Mar 23, 2022
    Configuration menu
    Copy the full SHA
    03b51a0 View commit details
    Browse the repository at this point in the history
  2. Update changelog

    david-perez committed Mar 23, 2022
    Configuration menu
    Copy the full SHA
    7cace8a View commit details
    Browse the repository at this point in the history
  3. Kick off CI

    david-perez committed Mar 23, 2022
    Configuration menu
    Copy the full SHA
    ab6f306 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    6130fcb View commit details
    Browse the repository at this point in the history

Commits on Apr 11, 2022

  1. Suggestions from PR

    david-perez committed Apr 11, 2022
    Configuration menu
    Copy the full SHA
    fc23fad View commit details
    Browse the repository at this point in the history
  2. Merge remote-tracking branch 'awslabs/main' into davidpz-refactor-con…

    …verters-to-numeric-types
    david-perez committed Apr 11, 2022
    Configuration menu
    Copy the full SHA
    ae129ec View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    c21572d View commit details
    Browse the repository at this point in the history

Commits on Jul 19, 2022

  1. Configuration menu
    Copy the full SHA
    8aba8cd View commit details
    Browse the repository at this point in the history

Commits on Aug 12, 2022

  1. Configuration menu
    Copy the full SHA
    e17da69 View commit details
    Browse the repository at this point in the history
  2. Merge remote-tracking branch 'upstream/main' into davidpz-refactor-co…

    …nverters-to-numeric-types
    david-perez committed Aug 12, 2022
    Configuration menu
    Copy the full SHA
    1f383c7 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    afffb9c View commit details
    Browse the repository at this point in the history
  4. Merge remote-tracking branch 'upstream/main' into davidpz-refactor-co…

    …nverters-to-numeric-types
    david-perez committed Aug 12, 2022
    Configuration menu
    Copy the full SHA
    a67cb97 View commit details
    Browse the repository at this point in the history

Commits on Aug 16, 2022

  1. appease ktlint

    david-perez committed Aug 16, 2022
    Configuration menu
    Copy the full SHA
    329a929 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    c0400f6 View commit details
    Browse the repository at this point in the history
  3. Merge remote-tracking branch 'upstream/main' into davidpz-refactor-co…

    …nverters-to-numeric-types
    david-perez committed Aug 16, 2022
    Configuration menu
    Copy the full SHA
    9b7fb96 View commit details
    Browse the repository at this point in the history

Commits on Aug 19, 2022

  1. Merge remote-tracking branch 'upstream/main' into davidpz-refactor-co…

    …nverters-to-numeric-types
    david-perez committed Aug 19, 2022
    Configuration menu
    Copy the full SHA
    752d632 View commit details
    Browse the repository at this point in the history