matrix_sdk_ffi/room_alias.rs
1use matrix_sdk::RoomDisplayName;
2
3/// Verifies the passed `String` matches the expected room alias format:
4///
5/// This means it's lowercase, with no whitespace chars, has a single leading
6/// `#` char and a single `:` separator between the local and domain parts, and
7/// the local part only contains characters that can't be percent encoded.
8#[matrix_sdk_ffi_macros::export]
9fn is_room_alias_format_valid(alias: String) -> bool {
10 matrix_sdk::utils::is_room_alias_format_valid(alias)
11}
12
13/// Transforms a Room's display name into a valid room alias name.
14#[matrix_sdk_ffi_macros::export]
15fn room_alias_name_from_room_display_name(room_name: String) -> String {
16 RoomDisplayName::Named(room_name).to_room_alias_name()
17}