#[derive(Copy, Clone, Debug, PartialEq)]
pub enum Criticality {
Critical,
Elective
}
#[inline]
pub fn get_criticality(option: u16) -> Criticality {
if option & 1 == 1 {
Criticality::Critical
} else {
Criticality::Elective
}
}
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum ProxySafety {
SafeToForward { cache_key: bool },
Unsafe,
}
#[inline]
pub fn get_proxy_safety(option: u16) -> ProxySafety {
if option & 0x02 == 0x02 {
ProxySafety::Unsafe
} else {
ProxySafety::SafeToForward { cache_key: option & 0x1e != 0x1c }
}
}
macro_rules! options {
( $( $num:tt $constname:ident $name:tt ) , * ) => { $(
#[doc=$name]
pub const $constname: u16 = $num;
)*
pub fn to_name(option: u16) -> Option<&'static str> {
match option {
$(
$constname => Some($name),
)*
_ => None
}
}
}
}
options!(
1 IF_MATCH "If-Match",
3 URI_HOST "Uri-Host",
4 ETAG "ETag",
5 IF_NONE_MATCH "If-None-Match",
6 OBSERVE "Observe",
7 URI_PORT "Uri-Port",
8 LOCATION_PATH "Location-Path",
9 OSCORE "OSCORE",
11 URI_PATH "Uri-Path",
12 CONTENT_FORMAT "Content-Format",
14 MAX_AGE "Max-Age",
15 URI_QUERY "Uri-Query",
16 HOP_LIMIT "Hop-Limit",
17 ACCEPT "Accept",
20 LOCATION_QUERY "Location-Query",
23 BLOCK2 "Block2",
27 BLOCK1 "Block1",
28 SIZE2 "Size2",
35 PROXY_URI "Proxy-Uri",
39 PROXY_SCHEME "Proxy-Scheme",
60 SIZE1 "Size1",
258 NO_RESPONSE "No-Response",
2049 OCF_ACCEPT_CONTENT_FORMAT_VERSION "OCF-Accept-Content-Format-Version",
2053 OCF_CONTENT_FORMAT_VERSION "OCF-Content-Format-Version"
);