Open david-perez opened 1 year ago
https://github.com/awslabs/smithy-rs/pull/2629 already uses const
in the following cases https://github.com/awslabs/smithy-rs/pull/2629/files#diff-da9c47cae3f2f75fc01b3625ee430f56f2f495870a77302c3c148e98f7341bd4R198-R200.
The migration to a const
constructable struct would follow the same pattern.
https://github.com/hyperium/mime/issues/153 proposes to solve these issues in mime
and actively maintain the crate. We work with other of their crates, if it's worth seeing what the proposal will look like and possibly continue with mime
We're currently creating one
OnceCell
per operation backing a staticmime::Mime
type for the operation's expected (if present) clientAccept
header value, only to then decompose it into type + subtype and perform a case-insensitive string comparison check against the actual incomingAccept
header value.It would be more efficient to directly compare
&str
s and avoid incurring the atomic read.A simpler, more efficient, and type-safe approach would be to directly switch to something like
mediatype
, which is const-constructible and zero-copy. Note thatmime
is not actively maintained.See https://github.com/awslabs/smithy-rs/pull/2607#discussion_r1173687692 and https://github.com/awslabs/smithy-rs/pull/2629, the PR where we started using
OnceCell
s for this.