Replace `Error::*Error(String)` with non-heap-allocating localizable enum variants
维护者通常 1 天内回复
@ctz 已经在做这个了。
开始于 2023年1月17日。
评估
这个 Issue 还没有评估数据。
描述
There are many places where we do things like this:
return Err(Error::General("No end-entity certificate in certificate chain".to_string()));
and
return Err(Error::PeerMisbehavedError("client sent wrong binder".to_string()));
Each of these does a heap allocation. There are many reasons why we want to reduce heap allocations in Rustls.
The most straightforward way of eliminating these allocations would be to use &'static str; this would also eliminate any possibility of (secret) application data getting into the strings. If that weren't practical, Cow<'static, str> would be another alternative.
However, in both of those cases, we're stuck with English strings in the error messages. We might as well replace the strings with an enum like this:
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum PeerMisbehavedError {
NoEndEntityCertificateInCertificateChain,
...
}
In the case of General, instead of creating a new enum, we might just add the enum variants to Error itself.
- 主要语言
- Rust
- 星标
- 7.7k
- 派生
- 947
- 平均合并
- 3 天 11 小时
- 30 天内合并 PR
- 46
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
rustls/rustls 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 70/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 22/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 55/100
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 12/100
rustls/rustls#3409 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 48/100
维护者通常 1 天内回复
相似的 Issue
-
ライブラリを追加未关闭priority middle
难度 1/5 1 小时以内 新手友好度 62/100
KATO-Hiro/AtCoderClans#13015 ·
维护者通常 1 天内回复
-
needs-review
难度 2/5 1-3 小时 新手友好度 70/100
UCS-Care-Group/mailcraft#1429 ·
维护者通常 1 天内回复
-
priority: medium ready
难度 1/5 1 小时以内 新手友好度 88/100
TusanHomichi/PSIV#646 ·
维护者通常 1 天内回复
-
area:tui bug P1
难度 2/5 1-3 小时 新手友好度 62/100
agent-of-empires/agent-of-empires#5705 · 1 条评论 ·
维护者通常 1 天内回复
-
bug lab rust-mcp
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复