Room IDs being splittable into localpart and servername does not have much inherent value and there are proposals like MSC4051¹ that propose changing the format. Relaxing the rules makes Ruma forwards-compatible with those proposals. The server_name accessor is kept because it is used by at least one downstream, but is updated to return an `Option`. ¹ https://github.com/matrix-org/matrix-spec-proposals/pull/4051
12 lines
262 B
Rust
12 lines
262 B
Rust
use crate::{validate_delimited_id, Error};
|
|
|
|
pub fn validate(s: &str) -> Result<(), Error> {
|
|
if s.contains(':') {
|
|
validate_delimited_id(s, b'$')?;
|
|
} else if !s.starts_with('$') {
|
|
return Err(Error::MissingLeadingSigil);
|
|
}
|
|
|
|
Ok(())
|
|
}
|