Replace `Error::*Error(String)` with non-heap-allocating localizable enum variants
Maintainers usually reply within 1 day
@ctz is already working on this.
Since Jan 17, 2023.
Assessment
This issue has not been assessed yet.
Description
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.
- Dominant language
- Rust
- Stars
- 7.7k
- Forks
- 947
- Avg merge
- 3d 11h
- Merged PRs (30d)
- 46
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rustls/rustls
-
Difficulty 1/5 Under an hour Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 22/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 55/100
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 12/100
rustls/rustls#3409 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
rustls/rustls#3373 · 3 comments ·
Maintainers usually reply within 1 day
Similar issues
-
ライブラリを追加Openpriority middle
Difficulty 1/5 Under an hour Newbie friendliness 62/100
KATO-Hiro/AtCoderClans#13015 ·
Maintainers usually reply within 1 day
-
needs-review
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
UCS-Care-Group/mailcraft#1429 ·
Maintainers usually reply within 1 day
-
priority: medium ready
Difficulty 1/5 Under an hour Newbie friendliness 88/100
TusanHomichi/PSIV#646 ·
Maintainers usually reply within 1 day
-
area:tui bug P1
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
agent-of-empires/agent-of-empires#5705 · 1 comment ·
Maintainers usually reply within 1 day
-
bug lab rust-mcp
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day