pub struct RoomOrAliasId(/* private fields */);Expand description
A Matrix room ID or a Matrix room alias ID.
RoomOrAliasId 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!(<&RoomOrAliasId>::try_from("#ruma:example.com").unwrap(), "#ruma:example.com");
assert_eq!(
<&RoomOrAliasId>::try_from("!n8f893n9:example.com").unwrap(),
"!n8f893n9:example.com"
);It can be converted to a RoomId or a RoomAliasId using ::try_from() / .try_into().
For example, <&RoomId>::try_from(room_or_alias_id) returns either Ok(room_id) or
Err(room_alias_id).
Implementations§
Source§impl RoomOrAliasId
impl RoomOrAliasId
Source§impl RoomOrAliasId
impl RoomOrAliasId
Source§impl RoomOrAliasId
impl RoomOrAliasId
Sourcepub fn server_name(&self) -> Option<&ServerName>
Available on crate feature events only.
pub fn server_name(&self) -> Option<&ServerName>
events only.Returns the server name of the room (alias) ID.
Sourcepub fn is_room_id(&self) -> bool
Available on crate feature events only.
pub fn is_room_id(&self) -> bool
events only.Whether this is a room id (starts with '!')
Sourcepub fn is_room_alias_id(&self) -> bool
Available on crate feature events only.
pub fn is_room_alias_id(&self) -> bool
events only.Whether this is a room alias id (starts with '#')
Trait Implementations§
Source§impl AsRef<[u8]> for RoomOrAliasId
impl AsRef<[u8]> for RoomOrAliasId
Source§impl AsRef<RoomOrAliasId> for OwnedRoomOrAliasId
impl AsRef<RoomOrAliasId> for OwnedRoomOrAliasId
Source§fn as_ref(&self) -> &RoomOrAliasId
fn as_ref(&self) -> &RoomOrAliasId
Converts this type into a shared reference of the (usually inferred) input type.
Source§impl AsRef<RoomOrAliasId> for RoomOrAliasId
impl AsRef<RoomOrAliasId> for RoomOrAliasId
Source§fn as_ref(&self) -> &RoomOrAliasId
fn as_ref(&self) -> &RoomOrAliasId
Converts this type into a shared reference of the (usually inferred) input type.
Source§impl AsRef<str> for RoomOrAliasId
impl AsRef<str> for RoomOrAliasId
Source§impl Borrow<RoomOrAliasId> for OwnedRoomOrAliasId
impl Borrow<RoomOrAliasId> for OwnedRoomOrAliasId
Source§fn borrow(&self) -> &RoomOrAliasId
fn borrow(&self) -> &RoomOrAliasId
Immutably borrows from an owned value. Read more
Source§impl Debug for RoomOrAliasId
impl Debug for RoomOrAliasId
Source§impl Display for RoomOrAliasId
impl Display for RoomOrAliasId
Source§impl<'a> From<&'a RoomAliasId> for &'a RoomOrAliasId
impl<'a> From<&'a RoomAliasId> for &'a RoomOrAliasId
Source§fn from(room_alias_id: &'a RoomAliasId) -> &'a RoomOrAliasId
fn from(room_alias_id: &'a RoomAliasId) -> &'a RoomOrAliasId
Converts to this type from the input type.
Source§impl<'a> From<&'a RoomId> for &'a RoomOrAliasId
impl<'a> From<&'a RoomId> for &'a RoomOrAliasId
Source§fn from(room_id: &'a RoomId) -> &'a RoomOrAliasId
fn from(room_id: &'a RoomId) -> &'a RoomOrAliasId
Converts to this type from the input type.
Source§impl From<&RoomOrAliasId> for OwnedRoomOrAliasId
impl From<&RoomOrAliasId> for OwnedRoomOrAliasId
Source§fn from(id: &RoomOrAliasId) -> OwnedRoomOrAliasId
fn from(id: &RoomOrAliasId) -> OwnedRoomOrAliasId
Converts to this type from the input type.
Source§impl From<&RoomOrAliasId> for String
impl From<&RoomOrAliasId> for String
Source§fn from(id: &RoomOrAliasId) -> String
fn from(id: &RoomOrAliasId) -> String
Converts to this type from the input type.
Source§impl Hash for RoomOrAliasId
impl Hash for RoomOrAliasId
Source§impl Ord for RoomOrAliasId
impl Ord for RoomOrAliasId
Source§impl PartialEq<&RoomOrAliasId> for OwnedRoomOrAliasId
impl PartialEq<&RoomOrAliasId> for OwnedRoomOrAliasId
Source§impl PartialEq<&str> for RoomOrAliasId
impl PartialEq<&str> for RoomOrAliasId
Source§impl PartialEq<OwnedRoomOrAliasId> for &RoomOrAliasId
impl PartialEq<OwnedRoomOrAliasId> for &RoomOrAliasId
Source§impl PartialEq<OwnedRoomOrAliasId> for RoomOrAliasId
impl PartialEq<OwnedRoomOrAliasId> for RoomOrAliasId
Source§impl PartialEq<RoomOrAliasId> for &str
impl PartialEq<RoomOrAliasId> for &str
Source§impl PartialEq<RoomOrAliasId> for OwnedRoomOrAliasId
impl PartialEq<RoomOrAliasId> for OwnedRoomOrAliasId
Source§impl PartialEq<RoomOrAliasId> for str
impl PartialEq<RoomOrAliasId> for str
Source§impl PartialEq<String> for RoomOrAliasId
impl PartialEq<String> for RoomOrAliasId
Source§impl PartialEq<str> for RoomOrAliasId
impl PartialEq<str> for RoomOrAliasId
Source§impl PartialEq for RoomOrAliasId
impl PartialEq for RoomOrAliasId
Source§impl PartialOrd for RoomOrAliasId
impl PartialOrd for RoomOrAliasId
Source§impl Serialize for RoomOrAliasId
impl Serialize for RoomOrAliasId
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
Source§impl ToOwned for RoomOrAliasId
impl ToOwned for RoomOrAliasId
Source§type Owned = OwnedRoomOrAliasId
type Owned = OwnedRoomOrAliasId
The resulting type after obtaining ownership.
Source§fn to_owned(&self) -> <RoomOrAliasId as ToOwned>::Owned
fn to_owned(&self) -> <RoomOrAliasId as ToOwned>::Owned
Creates owned data from borrowed data, usually by cloning. Read more
1.63.0 · Source§fn clone_into(&self, target: &mut Self::Owned)
fn clone_into(&self, target: &mut Self::Owned)
Uses borrowed data to replace owned data, usually by cloning. Read more
Source§impl<'a> TryFrom<&'a RoomOrAliasId> for &'a RoomAliasId
impl<'a> TryFrom<&'a RoomOrAliasId> for &'a RoomAliasId
Source§impl<'a> TryFrom<&'a RoomOrAliasId> for &'a RoomId
impl<'a> TryFrom<&'a RoomOrAliasId> for &'a RoomId
Source§type Error = &'a RoomAliasId
type Error = &'a RoomAliasId
The type returned in the event of a conversion error.
Source§fn try_from(id: &'a RoomOrAliasId) -> Result<&'a RoomId, &'a RoomAliasId>
fn try_from(id: &'a RoomOrAliasId) -> Result<&'a RoomId, &'a RoomAliasId>
Performs the conversion.
Source§impl<'a> TryFrom<&'a str> for &'a RoomOrAliasId
impl<'a> TryFrom<&'a str> for &'a RoomOrAliasId
impl Eq for RoomOrAliasId
impl StructuralPartialEq for RoomOrAliasId
Auto Trait Implementations§
impl Freeze for RoomOrAliasId
impl RefUnwindSafe for RoomOrAliasId
impl Send for RoomOrAliasId
impl !Sized for RoomOrAliasId
impl Sync for RoomOrAliasId
impl Unpin for RoomOrAliasId
impl UnwindSafe for RoomOrAliasId
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.