#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum PercentEncodingMode {
Rfc3986,
FormUrlencoded,
}
impl PercentEncodingMode {
#[must_use]
#[inline]
pub(crate) fn is_unescaped(self, byte: u8) -> bool {
match self {
Self::Rfc3986 => matches!(
byte,
b'A'..=b'Z'
| b'a'..=b'z'
| b'0'..=b'9'
| b'-'
| b'.'
| b'_'
| b'~'
),
Self::FormUrlencoded => matches!(
byte,
b'A'..=b'Z'
| b'a'..=b'z'
| b'0'..=b'9'
| b'*'
| b'-'
| b'.'
| b'_'
),
}
}
#[must_use]
#[inline]
pub(crate) fn is_space_plus(self, byte: u8) -> bool {
matches!(self, Self::FormUrlencoded) && byte == b' '
}
}