use crate::{
parser::char::is_ucschar,
spec::{IriSpec, UriSpec},
};
pub trait Sealed: SpecInternal {}
impl Sealed for IriSpec {}
impl Sealed for UriSpec {}
pub trait SpecInternal: Sized {
fn is_char_unreserved(c: char) -> bool;
fn is_char_private(c: char) -> bool;
}
impl SpecInternal for IriSpec {
#[inline]
fn is_char_unreserved(c: char) -> bool {
UriSpec::is_char_unreserved(c) || is_ucschar(c)
}
fn is_char_private(c: char) -> bool {
matches!(
u32::from(c),
0xE000..=0xF8FF |
0xF_0000..=0xF_FFFD |
0x10_0000..=0x10_FFFD
)
}
}
impl SpecInternal for UriSpec {
fn is_char_unreserved(c: char) -> bool {
c.is_ascii_alphanumeric() || c == '-' || c == '.' || c == '_' || c == '~'
}
#[inline]
fn is_char_private(_: char) -> bool {
false
}
}