Skip to content

Removing Bytes from the public API #366

Closed
@seanmonstar

Description

@seanmonstar

We'd like to disconnect the stability if the http crate from the bytes crate. However, using Bytes 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    B-rfcBlocked: request for comments. More discussion would help move this along.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions