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

Introduce ByteUnit #147

Merged
merged 2 commits into from
Jan 4, 2024
Merged

Introduce ByteUnit #147

merged 2 commits into from
Jan 4, 2024

Conversation

LukeMathWalker
Copy link
Owner

Manipulating bytes as usizes is... clunky.
I find myself commenting on relevant lines with the value converted in the most relevant unit (e.g. MB or GB). That's a clear-cut code smell if I've ever seen one.

We introduce ByteUnit by re-exporting from the ubyte crate. It is used in rocket and it fits our needs perfectly.

⚠️ Breaking change: I renamed max_n_bytes to max_size in BodySizeLimit. The type has also changed from usize to ByteUnit. This impacts you if you were registering a custom constructor for BodySizeLimit. The same applies to the SizeLimitExceeded error.

@LukeMathWalker LukeMathWalker merged commit c9e1478 into main Jan 4, 2024
5 checks passed
@LukeMathWalker LukeMathWalker deleted the byte-unit branch January 4, 2024 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant