Skip to main content

alux_http/
answer.rs

1//! States which headers an answer carries, beside the body it states.
2
3/// States one header an answer carries.
4///
5/// A name is all a header is to a program. What an interpretation does with one is the same whatever
6/// the name, so a header a specification does not state is a marker a domain writes for itself, and
7/// no interpretation changes.
8pub trait HeaderNameAlg {
9    /// The name this header is written under, as the wire spells one.
10    const HEADER_NAME: &'static str;
11}
12
13macro_rules! header_names {
14    ($($marker:ident => $name:literal),+ $(,)?) => {
15        $(
16            #[doc = concat!("States the `", $name, "` header an answer carries.")]
17            #[derive(Debug, Default)]
18            pub struct $marker;
19
20            impl HeaderNameAlg for $marker {
21                const HEADER_NAME: &'static str = $name;
22            }
23        )+
24    };
25}
26
27header_names! {
28    CacheControl       => "cache-control",
29    ContentDisposition => "content-disposition",
30    ContentLanguage    => "content-language",
31    ETag               => "etag",
32    Expires            => "expires",
33    LastModified       => "last-modified",
34    Link               => "link",
35    Location           => "location",
36    RetryAfter         => "retry-after",
37    Vary               => "vary",
38}