#[derive(Copy, Clone, Debug, PartialEq)]
pub enum Criticality {
Critical,
Elective,
}
#[inline]
#[must_use]
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]
#[must_use]
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 ) , * , ) => { $(
#[allow(
clippy::doc_markdown,
// 'ETag' is the preferred capitalization, but clippy would complain
// Can become reason= once MSRV changes.
)]
#[doc=$name]
pub const $constname: u16 = $num;
)*
#[must_use]
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",
19 Q_BLOCK1 "Q-Block1",
20 LOCATION_QUERY "Location-Query",
21 EDHOC "EDHOC",
23 BLOCK2 "Block2",
27 BLOCK1 "Block1",
28 SIZE2 "Size2",
31 Q_BLOCK2 "Q-Block2",
35 PROXY_URI "Proxy-Uri",
39 PROXY_SCHEME "Proxy-Scheme",
60 SIZE1 "Size1",
235 PROXY_CRI "Proxy-Cri",
239 PROXY_SCHEME_NUMBER "Proxy-Scheme-Number",
252 ECHO "Echo",
258 NO_RESPONSE "No-Response",
292 REQUEST_TAG "Request-Tag",
2049 OCF_ACCEPT_CONTENT_FORMAT_VERSION "OCF-Accept-Content-Format-Version",
2053 OCF_CONTENT_FORMAT_VERSION "OCF-Content-Format-Version",
2055 SCP82_PARAMS "SCP82-Params",
2056 X_ADMIN_PROTOCOL "X-Admin-Protocol",
);