From 373a1ecb20b4d71086a1b5a578f26ab0d4197191 Mon Sep 17 00:00:00 2001 From: david-perez Date: Wed, 18 Jan 2023 14:35:08 +0100 Subject: [PATCH] Derive `Eq` and `Hash` wherever possible In server SDKs, these traits can be implemented by any shape _except_ if the shape's closure contains: 1. A `float`, `double`, or `document` shape: floating point types in Rust do not implement `Eq`. Similarly, [`document` shapes] may contain arbitrary JSON-like data containing floating point values. 2. A [@streaming] shape: all the streaming data would need to be buffered first to compare it. Additionally, the `Hash` trait cannot be implemented by shapes whose closure contains: 1. A `map` shape: we render `map` shapes as `std::collections::HashMap`, which _do not_ implement `Hash`. See https://github.com/awslabs/smithy/issues/1567. In **client SDKs, these traits cannot be derived on any code-generated Rust types corresponding to Smithy shapes**, since e.g. adding new optional members to a structure [is a backwards-compatible change], and doing so alters the semantics of these traits. However, this commit does implement these traits for the `aws_smithy_types::date_time::DateTime` and `aws_smithy_types::Blob` runtime types. This change is necessary to efficiently implement the `@uniqueItems` constraint trait in server SDKs. [`Eq`]: https://doc.rust-lang.org/std/cmp/trait.Eq.html [`Hash`]: https://doc.rust-lang.org/std/hash/trait.Hash.html [`document` shapes]: https://smithy.io/2.0/spec/simple-types.html#document [@streaming]: https://smithy.io/2.0/spec/streaming.html [is a backwards-compatible change]: https://smithy.io/2.0/guides/evolving-models.html#updating-structures