ruma_identifiers_validation/
base64_public_key.rs

1
2
3
4
5
6
7
8
9
10
use crate::Error;

pub fn validate(s: &str) -> Result<(), Error> {
    if s.is_empty() {
        return Err(Error::Empty);
    } else if !s.chars().all(|c| c.is_alphanumeric() || matches!(c, '+' | '/' | '=')) {
        return Err(Error::InvalidCharacters);
    }
    Ok(())
}