Add Option<&'static [u8]> method for header names
まだ誰も着手していません。
評価
調査の方向性
まずヘッダー名の表現と既存の as_bytes メソッドを見つけ、次に標準ヘッダー名がどのように識別されているかを調べます。提案されたメソッドを追加し、標準の ASCII 名では静的バイト列を公開できるようにし、それ以外の名前では None を返すようにして、両方のケースを対象とするテストを追加します。Issue では特定のファイルやテストパスは言及されていません。
索引モデルが issue の本文から書いたものです。
説明
Description
This enhancement focuses on improving the usability of the http crate when integrating Rust HTTP libraries with other VM engines, such as V8 (specifically for, but not limited to Deno). The goal is to provide embedding users with a specific method that allows extracting a static 7-bit string from a well-known ASCII header name. By treating header strings as interned strings in scripting engines [1] [2], we can effectively reduce garbage collection pressure, leading to enhanced performance and efficiency.
To achieve this, we propose introducing an Option<&'static [u8]> method for header names. This approach offers a more efficient means of passing header names across embedding boundaries. When working with static ASCII header names, this method allows direct access to the header name bytes across embedding boundaries, without the need for additional memory allocation or garbage collection overhead.
This may also be useful for Python embedders [2], as (I believe) the CPython engine allows creation of strings from const 1-byte buffers.
Alternatives
While we do have an as_bytes method on a header name, this does not tell us the provenance of those bytes, and whether the header is a StandardHeader. We cannot use these as "externally interned" strings in an embedding context because they may be allocated.
The hash function of the header could be used allow us to map between standard headers and interned strings in the embedded engine, but this requires an additional string comparison operation.
References
[1] V8's NewExternalOneByte method:
[2] Python's PyUnicode_FromKindAndData method (which I believe will avoid copies where necessary):
https://docs.python.org/3/c-api/unicode.html#c.PyUnicode_FromKindAndData
- 主要言語
- Rust
- スター
- 1.4k
- フォーク
- 385
- 平均マージ
- 1日 5時間
- マージ済み PR(30日)
- 2
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
hyperium/http のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 52/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 62/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 58/100
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
bytecodealliance/rustix#1703 ·
メンテナーはふだん 3 日以内に返信
-
bug discussion
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
medialab/xan#1201 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
farion1231/cc-switch#8298 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
ajeetdsouza/zoxide#1323 ·
メンテナーはふだん 1 日以内に返信