Enum ruma_identifiers::RoomIdOrAliasId [] [src]

pub enum RoomIdOrAliasId {
    RoomAliasId(RoomAliasId),
    RoomId(RoomId),
}

A Matrix room ID or a Matrix room alias ID.

RoomIdOrAliasId is useful for APIs that accept either kind of room identifier. It is converted from a string slice, and can be converted back into a string as needed. When converted from a string slice, the variant is determined by the leading sigil character.

assert_eq!(
    RoomIdOrAliasId::try_from("#ruma:example.com").unwrap().to_string(),
    "#ruma:example.com"
);

assert_eq!(
    RoomIdOrAliasId::try_from("!n8f893n9:example.com").unwrap().to_string(),
    "!n8f893n9:example.com"
);

Variants

A Matrix room alias ID.

A Matrix room ID.

Trait Implementations

impl Clone for RoomIdOrAliasId
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for RoomIdOrAliasId
[src]

Formats the value using the given formatter.

impl Eq for RoomIdOrAliasId
[src]

impl Hash for RoomIdOrAliasId
[src]

Feeds this value into the state given, updating the hasher as necessary.

Feeds a slice of this type into the state provided.

impl PartialEq for RoomIdOrAliasId
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Display for RoomIdOrAliasId
[src]

Formats the value using the given formatter.

impl Serialize for RoomIdOrAliasId
[src]

Serialize this value into the given Serde serializer. Read more

impl Deserialize for RoomIdOrAliasId
[src]

Deserialize this value from the given Serde deserializer. Read more

impl<'a> TryFrom<&'a str> for RoomIdOrAliasId
[src]

🔬 This is a nightly-only experimental API.   (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API.   (try_from)

Attempts to create a new Matrix room ID or a room alias ID from a string representation.

The string must either include the leading ! sigil, the opaque ID, a literal colon, and a valid server name or include the leading # sigil, the alias, a literal colon, and a valid server name.