Allow `Header` to borrow from the header value
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 30/100
Hướng nghiên cứu
Start by reviewing the Header trait and its decode and encode entry points, then inspect the Cookie header's handling of HeaderValue data. Compare the proposed lifetime-based API with the existing typed-header implementations and consider the stated Cow or multiple-header tradeoff. Done means the borrowing design is agreed on and existing header behavior remains covered by the test suite.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Currently all typed headers must copy and allocate their own storage for any string data it needs to store. This seems a bit wasteful in common headers such as Cookie where we should really just be able to borrow the existing value instead of copying the entire thing.
I'd like to propose a small change to the Header trait such that it takes a lifetime which allows the decode method to be implemented in a way that borrows the HeaderValues taken as argument.
pub trait Header<'value> {
/// The name of this header.
fn name() -> &'static HeaderName;
/// Decode this type from an iterator of `HeaderValue`s.
fn decode<I>(values: &mut I) -> Result<Self, Error>
where
Self: Sized,
I: Iterator<Item = &'value HeaderValue>;
/// Encode this type to a `HeaderMap`.
///
/// This function should be infallible. Any errors converting to a
/// `HeaderValue` should have been caught when parsing or constructing
/// this value.
fn encode<E: Extend<HeaderValue>>(&self, values: &mut E);
}
Drawbacks
- Increased complexity
- Some headers (Cookie) merges the
HeaderValuewhich forces aCowor the merging must be replaced by storing multiple headers in aVec/SmallVecinstead.
- Ngôn ngữ chính
- Rust
- Star
- 200
- Fork
- 108
- Merge trung bình
- 3 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 2
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của hyperium/headers
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
-
Range::bytes and ContentRange::bytes do unchecked u64 arithmetic on boundsCó thể đã có người làm @youdie006 đã nhận 57 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 78/100
-
From<SystemTime> for HttpDate panics on times before 1970 or after year 9999Có thể đã có người làm @SAY-5 đã nhận 76 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
-
Link supportĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
Tất cả issue của hyperium/headers
Issue tương tự
-
awaiting-response bug needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
wildcard/caro#1562 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
objectionary/sodg.rs#301 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
HakanSeven12/OpenCADStudio#1706 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] Completion info popup (.cm-completionInfo) ignores the configured editor fontCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởbug user-priority/P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
t8y2/dbx#11718 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
rescript-lang/rescript#8765 ·
Maintainer thường phản hồi trong vòng 1 ngày