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

Remove Bytes from the public API #369

Merged
merged 3 commits into from
Dec 2, 2019
Merged

Remove Bytes from the public API #369

merged 3 commits into from
Dec 2, 2019

Conversation

seanmonstar
Copy link
Member

This should remove Bytes from the public API while it is unstable, and adds from_maybe_shared generic constructors that can allow improved performance (less copies) if the correct version of Bytes is used.

Closes #366

@seanmonstar
Copy link
Member Author

seanmonstar commented Dec 2, 2019

cc @LucioFranco @sfackler

@sfackler
Copy link
Contributor

sfackler commented Dec 2, 2019

Is the idea that the next release of http will be 1.0?

@seanmonstar
Copy link
Member Author

I'm strongly considering it, or otherwise a 0.2 meant as a preview of 1.0 just to check the new changes.

src/uri/scheme.rs Outdated Show resolved Hide resolved
Copy link
Member

@LucioFranco LucioFranco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine with me

@LucioFranco
Copy link
Member

I'm also happy to go 1.0 with http

Removes `from_shared` and `try_from` constructors for all types.
We reserved these extra error types with the goal of possibly returning
the source `Bytes` in the error type, but no one has since need this.
Since the dependency on `bytes` is being made private, it made sense to
remove these otherwise unused error types.

Removes:

- `InvalidUriBytes`
- `InvalidHeaderNameBytes`
- `InvalidHeaderValueBytes`
These constructors don't expose the internal `Bytes` type, but instead
will try to downcast the argument to prevent a copy. If the types don't
match up (a user provides an older version of `Bytes`), the value will
just be copied.

Adds:

- `HeaderValue::from_maybe_shared`
- `HeaderValue::from_maybe_shared_unchecked`
- `Uri::from_maybe_shared`
- `Authority::from_maybe_shared`
- `PathAndQuery::from_maybe_shared`
@seanmonstar seanmonstar merged commit cb67c17 into master Dec 2, 2019
@seanmonstar seanmonstar deleted the try-shared branch December 2, 2019 21:12
@tesaguri tesaguri mentioned this pull request Nov 4, 2020
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.

Removing Bytes from the public API
4 participants