Add Option<&'static [u8]> method for header names
还没有人认领这个 Issue。
评估
调研方向
首先定位 header 名称的表示形式及其现有的 as_bytes 方法,然后检查标准 header 名称是如何被识别的。添加提议的方法,使标准 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
- 平均合并
- 2 天 4 小时
- 30 天内合并 PR
- 1
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
hyperium/http 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 4/5 3-5 天 新手友好度 45/100
-
难度 3/5 1-2 天 新手友好度 62/100
-
难度 3/5 1-2 天 新手友好度 58/100
-
难度 3/5 1-2 天 新手友好度 62/100
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
akitaonrails/ai-memory#1225 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
acsandmann/rift#577 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
-
[Bug]: rerank on the huggingface provider (TEI) always costs $0, configured input_cost_per_query is ignored可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭llm translation
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复