use crate::Error;
#[allow(dead_code)]
pub(crate) fn validate_protocol(protocol: &str) -> Result<(), Error> {
if protocol.is_empty() {
return Err(Error::InvalidProtocol(protocol.to_string()));
}
for c in protocol.chars() {
if !is_tchar(c) {
return Err(Error::InvalidProtocol(protocol.to_string()));
}
}
Ok(())
}
fn is_tchar(c: char) -> bool {
matches!(c,
'a'..='z' | 'A'..='Z' | '0'..='9'
| '!' | '#' | '$' | '%' | '&' | '\'' | '*' | '+' | '-' | '.' | '^' | '_' | '`' | '|' | '~'
)
}