You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We'd like to disconnect the stability if the http crate from the bytes crate. However, usingBytes inside https types facilitates improved performance by reducing copies (especially as headers and URIs can be quite long in the real world).
This proposes a way forward without sacrificing either case:
Remove all public APIs that uses Bytes. This includes from_shared, TryFrom impls, and into_bytes methods.
Add from_maybe_shared<T: AsRef<[u8]> + 'static> constructors to types that would most benefit. These constructors could downcast the value into a Bytes if the versions match, and perform a copy if they don't. While a copy not caught at compile-time is unfortunate, the alternatives seem worse.
The text was updated successfully, but these errors were encountered:
With from_bytes reserved for from_bytes(&[u8]) (with an implicit '_ lifetime), from_maybe_shared<T: AsRef<[u8]> + 'static> feels like the correct name until Bytes is 1.0, at which point, this could be revisited.
We'd like to disconnect the stability if the
http
crate from thebytes
crate. However, usingBytes
insidehttp
s types facilitates improved performance by reducing copies (especially as headers and URIs can be quite long in the real world).This proposes a way forward without sacrificing either case:
Bytes
. This includesfrom_shared
,TryFrom
impls, andinto_bytes
methods.from_maybe_shared<T: AsRef<[u8]> + 'static>
constructors to types that would most benefit. These constructors could downcast the value into aBytes
if the versions match, and perform a copy if they don't. While a copy not caught at compile-time is unfortunate, the alternatives seem worse.The text was updated successfully, but these errors were encountered: