pub use self::{
content_type::ContentType, etag::ETag, if_modified_since::IfModifiedSince,
if_none_match::IfNoneMatch, last_modified::LastModified,
};
mod content_type;
mod etag;
mod if_modified_since;
mod if_none_match;
mod last_modified;
pub trait Header: Sized {
fn header_name() -> http::HeaderName;
fn decode(value: &http::HeaderValue) -> Option<Self>;
fn encode(self) -> http::HeaderValue;
}
pub trait HeaderMapExt {
fn typed_get<H: Header>(&self) -> Option<H>;
fn typed_insert<H: Header>(&mut self, header: H);
}
impl HeaderMapExt for http::HeaderMap {
fn typed_get<H: Header>(&self) -> Option<H> {
self.get(H::header_name())
.and_then(|value| H::decode(value))
}
fn typed_insert<H: Header>(&mut self, header: H) {
self.insert(H::header_name(), header.encode());
}
}