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

More efficient mime type parsing in server SDKs; avoid mime crate #2666

Open
david-perez opened this issue May 3, 2023 · 2 comments
Open
Labels
good first issue Good for newcomers high-priority High priority issue server Rust server SDK

Comments

@david-perez
Copy link
Contributor

We're currently creating one OnceCell per operation backing a static mime::Mime type for the operation's expected (if present) client Accept header value, only to then decompose it into type + subtype and perform a case-insensitive string comparison check against the actual incoming Accept header value.

It would be more efficient to directly compare &strs 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 that mime is not actively maintained.

See #2607 (comment) and #2629, the PR where we started using OnceCells for this.

@hlbarber
Copy link
Contributor

hlbarber commented May 3, 2023

#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.

@82marbag
Copy link
Contributor

hyperium/mime#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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers high-priority High priority issue server Rust server SDK
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants