Skip to content

Conversation

@pyrrho
Copy link

@pyrrho pyrrho commented Jan 19, 2026

This change adds,

  • 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::[try_]slice which mirrors the Bytes::slice interface, and provides copy-free construction of sub-sliced HeaderValues.
  • HeaderName::as_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.

Add .slice to HeaderValue, provide access to the backing Bytes objects

This change adds,
- `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::[try_]slice` which mirrors the `Bytes::slice` interface,
  and provides copy-free construction of sub-sliced `HeaderValue`s.
- `HeaderName::as_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`.

Add .slice to HeaderValue, provide access to the backing Bytes objects
@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.

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