Skip to content

Conversation

@pyrrho
Copy link

@pyrrho pyrrho commented Jan 19, 2026

This change adds (or makes public),

  • HeaderValue::from_shared[_unchecked] which directly accept a Bytes
    object as an argument. This should allow for lwss copying when
    constructing HeaderValues from pre-existing Bytes buffers.
  • HeaderValue::as_shared which returns a clone of the Bytes object
    that backs the given HeaderValue.
  • HeaderValue::into_shared which is a self-consuming version of the
    above.
  • HeaderValue::[try_]slice which mirrors the Bytes::slice interface,
    and provides copy-free construction of sub-sliced HeaderValues.
  • HeaderName::into_shared which is a rename of the previously
    pub(crate) .into_bytes method. Allows access to a Bytes
    representation of a HeaderName, though it will usually copy via
    Bytes::from_static.
  • Uri::from_shared which was previously pub(crate) and is now
    pub with an expanded doc comment.

@pyrrho
Copy link
Author

pyrrho commented Jan 19, 2026

This is an alternative to #811 with a few more bells and whistles.

Fixes #661 and #810. Part of #459.

This change adds (or makes public),
- `HeaderValue::from_shared[_unchecked]` which directly accept a `Bytes`
  object as an argument. This should allow for lwss copying when
  constructing `HeaderValue`s from pre-existing `Bytes` buffers.
- `HeaderValue::as_shared` which returns a clone of the `Bytes` object
  that backs the given `HeaderValue`.
- `HeaderValue::into_shared` which is a self-consuming version of the
  above.
- `HeaderValue::[try_]slice` which mirrors the `Bytes::slice` interface,
  and provides copy-free construction of sub-sliced `HeaderValue`s.
- `HeaderName::into_shared` which is a rename of the previously
  `pub(crate)` `.into_bytes` method. Allows access to a `Bytes`
  representation of a HeaderName, though it will usually copy via
  `Bytes::from_static`.
- `Uri::from_shared` which was previously `pub(crate)` and is now
  `pub` with an expanded doc comment.
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