Struct matrix_sdk_base::ruma::RoomOrAliasId
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"
);
Implementations§
§impl RoomOrAliasId
impl RoomOrAliasId
§impl RoomOrAliasId
impl RoomOrAliasId
pub fn parse(s: impl AsRef<str>) -> Result<OwnedRoomOrAliasId, Error>
pub fn parse(s: impl AsRef<str>) -> Result<OwnedRoomOrAliasId, Error>
Try parsing a &str
into an OwnedRoomOrAliasId
.
The same can also be done using FromStr
, TryFrom
or TryInto
.
This function is simply more constrained and thus useful in generic contexts.
pub fn parse_box(
s: impl AsRef<str> + Into<Box<str>>
) -> Result<Box<RoomOrAliasId>, Error>
pub fn parse_box( s: impl AsRef<str> + Into<Box<str>> ) -> Result<Box<RoomOrAliasId>, Error>
Try parsing a &str
into a Box<RoomOrAliasId>
.
The same can also be done using FromStr
, TryFrom
or TryInto
.
This function is simply more constrained and thus useful in generic contexts.
§impl RoomOrAliasId
impl RoomOrAliasId
pub fn server_name(&self) -> Option<&ServerName>
pub fn server_name(&self) -> Option<&ServerName>
Returns the server name of the room (alias) ID.
pub fn is_room_id(&self) -> bool
pub fn is_room_id(&self) -> bool
Whether this is a room id (starts with '!'
)
pub fn is_room_alias_id(&self) -> bool
pub fn is_room_alias_id(&self) -> bool
Whether this is a room alias id (starts with '#'
)
Trait Implementations§
§impl AsRef<[u8]> for RoomOrAliasId
impl AsRef<[u8]> for RoomOrAliasId
§impl AsRef<RoomOrAliasId> for OwnedRoomOrAliasId
impl AsRef<RoomOrAliasId> for OwnedRoomOrAliasId
§fn as_ref(&self) -> &RoomOrAliasId
fn as_ref(&self) -> &RoomOrAliasId
§impl AsRef<RoomOrAliasId> for RoomOrAliasId
impl AsRef<RoomOrAliasId> for RoomOrAliasId
§fn as_ref(&self) -> &RoomOrAliasId
fn as_ref(&self) -> &RoomOrAliasId
§impl AsRef<str> for RoomOrAliasId
impl AsRef<str> for RoomOrAliasId
§impl Borrow<RoomOrAliasId> for OwnedRoomOrAliasId
impl Borrow<RoomOrAliasId> for OwnedRoomOrAliasId
§fn borrow(&self) -> &RoomOrAliasId
fn borrow(&self) -> &RoomOrAliasId
§impl Clone for Box<RoomOrAliasId>
impl Clone for Box<RoomOrAliasId>
§fn clone(&self) -> Box<RoomOrAliasId>
fn clone(&self) -> Box<RoomOrAliasId>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl Debug for RoomOrAliasId
impl Debug for RoomOrAliasId
§impl<'de> Deserialize<'de> for Box<RoomOrAliasId>
impl<'de> Deserialize<'de> for Box<RoomOrAliasId>
§fn deserialize<D>(
deserializer: D
) -> Result<Box<RoomOrAliasId>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D
) -> Result<Box<RoomOrAliasId>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
§impl Display for RoomOrAliasId
impl Display for RoomOrAliasId
§impl<'a> From<&'a RoomAliasId> for &'a RoomOrAliasId
impl<'a> From<&'a RoomAliasId> for &'a RoomOrAliasId
§fn from(room_alias_id: &'a RoomAliasId) -> &'a RoomOrAliasId
fn from(room_alias_id: &'a RoomAliasId) -> &'a RoomOrAliasId
§impl<'a> From<&'a RoomId> for &'a RoomOrAliasId
impl<'a> From<&'a RoomId> for &'a RoomOrAliasId
§fn from(room_id: &'a RoomId) -> &'a RoomOrAliasId
fn from(room_id: &'a RoomId) -> &'a RoomOrAliasId
§impl From<&RoomOrAliasId> for Arc<RoomOrAliasId>
impl From<&RoomOrAliasId> for Arc<RoomOrAliasId>
§fn from(s: &RoomOrAliasId) -> Arc<RoomOrAliasId>
fn from(s: &RoomOrAliasId) -> Arc<RoomOrAliasId>
§impl From<&RoomOrAliasId> for Box<RoomOrAliasId>
impl From<&RoomOrAliasId> for Box<RoomOrAliasId>
§fn from(id: &RoomOrAliasId) -> Box<RoomOrAliasId>
fn from(id: &RoomOrAliasId) -> Box<RoomOrAliasId>
§impl From<&RoomOrAliasId> for OwnedRoomOrAliasId
impl From<&RoomOrAliasId> for OwnedRoomOrAliasId
§fn from(id: &RoomOrAliasId) -> OwnedRoomOrAliasId
fn from(id: &RoomOrAliasId) -> OwnedRoomOrAliasId
§impl From<&RoomOrAliasId> for Rc<RoomOrAliasId>
impl From<&RoomOrAliasId> for Rc<RoomOrAliasId>
§fn from(s: &RoomOrAliasId) -> Rc<RoomOrAliasId>
fn from(s: &RoomOrAliasId) -> Rc<RoomOrAliasId>
§impl From<&RoomOrAliasId> for String
impl From<&RoomOrAliasId> for String
§fn from(id: &RoomOrAliasId) -> String
fn from(id: &RoomOrAliasId) -> String
§impl From<OwnedRoomOrAliasId> for Box<RoomOrAliasId>
impl From<OwnedRoomOrAliasId> for Box<RoomOrAliasId>
§fn from(a: OwnedRoomOrAliasId) -> Box<RoomOrAliasId>
fn from(a: OwnedRoomOrAliasId) -> Box<RoomOrAliasId>
§impl Hash for RoomOrAliasId
impl Hash for RoomOrAliasId
§impl Ord for RoomOrAliasId
impl Ord for RoomOrAliasId
§impl PartialEq<&RoomOrAliasId> for OwnedRoomOrAliasId
impl PartialEq<&RoomOrAliasId> for OwnedRoomOrAliasId
§fn eq(&self, other: &&RoomOrAliasId) -> bool
fn eq(&self, other: &&RoomOrAliasId) -> bool
self
and other
values to be equal, and is used
by ==
.§impl PartialEq<&str> for RoomOrAliasId
impl PartialEq<&str> for RoomOrAliasId
§impl PartialEq<Box<RoomOrAliasId>> for &RoomOrAliasId
impl PartialEq<Box<RoomOrAliasId>> for &RoomOrAliasId
§fn eq(&self, other: &Box<RoomOrAliasId>) -> bool
fn eq(&self, other: &Box<RoomOrAliasId>) -> bool
self
and other
values to be equal, and is used
by ==
.§impl PartialEq<Box<RoomOrAliasId>> for RoomOrAliasId
impl PartialEq<Box<RoomOrAliasId>> for RoomOrAliasId
§fn eq(&self, other: &Box<RoomOrAliasId>) -> bool
fn eq(&self, other: &Box<RoomOrAliasId>) -> bool
self
and other
values to be equal, and is used
by ==
.§impl PartialEq<OwnedRoomOrAliasId> for &RoomOrAliasId
impl PartialEq<OwnedRoomOrAliasId> for &RoomOrAliasId
§fn eq(&self, other: &OwnedRoomOrAliasId) -> bool
fn eq(&self, other: &OwnedRoomOrAliasId) -> bool
self
and other
values to be equal, and is used
by ==
.§impl PartialEq<OwnedRoomOrAliasId> for RoomOrAliasId
impl PartialEq<OwnedRoomOrAliasId> for RoomOrAliasId
§fn eq(&self, other: &OwnedRoomOrAliasId) -> bool
fn eq(&self, other: &OwnedRoomOrAliasId) -> bool
self
and other
values to be equal, and is used
by ==
.§impl PartialEq<RoomOrAliasId> for &str
impl PartialEq<RoomOrAliasId> for &str
§fn eq(&self, other: &RoomOrAliasId) -> bool
fn eq(&self, other: &RoomOrAliasId) -> bool
self
and other
values to be equal, and is used
by ==
.§impl PartialEq<RoomOrAliasId> for OwnedRoomOrAliasId
impl PartialEq<RoomOrAliasId> for OwnedRoomOrAliasId
§fn eq(&self, other: &RoomOrAliasId) -> bool
fn eq(&self, other: &RoomOrAliasId) -> bool
self
and other
values to be equal, and is used
by ==
.§impl PartialEq<RoomOrAliasId> for String
impl PartialEq<RoomOrAliasId> for String
§fn eq(&self, other: &RoomOrAliasId) -> bool
fn eq(&self, other: &RoomOrAliasId) -> bool
self
and other
values to be equal, and is used
by ==
.§impl PartialEq<RoomOrAliasId> for str
impl PartialEq<RoomOrAliasId> for str
§fn eq(&self, other: &RoomOrAliasId) -> bool
fn eq(&self, other: &RoomOrAliasId) -> bool
self
and other
values to be equal, and is used
by ==
.§impl PartialEq<String> for RoomOrAliasId
impl PartialEq<String> for RoomOrAliasId
§impl PartialEq<str> for RoomOrAliasId
impl PartialEq<str> for RoomOrAliasId
§impl PartialEq for RoomOrAliasId
impl PartialEq for RoomOrAliasId
§fn eq(&self, other: &RoomOrAliasId) -> bool
fn eq(&self, other: &RoomOrAliasId) -> bool
self
and other
values to be equal, and is used
by ==
.§impl PartialOrd for RoomOrAliasId
impl PartialOrd for RoomOrAliasId
§fn partial_cmp(&self, other: &RoomOrAliasId) -> Option<Ordering>
fn partial_cmp(&self, other: &RoomOrAliasId) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more§impl Serialize for RoomOrAliasId
impl Serialize for RoomOrAliasId
§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,
§impl ToOwned for RoomOrAliasId
impl ToOwned for RoomOrAliasId
§type Owned = OwnedRoomOrAliasId
type Owned = OwnedRoomOrAliasId
§fn to_owned(&self) -> <RoomOrAliasId as ToOwned>::Owned
fn to_owned(&self) -> <RoomOrAliasId as ToOwned>::Owned
1.63.0 · source§fn clone_into(&self, target: &mut Self::Owned)
fn clone_into(&self, target: &mut Self::Owned)
§impl<'a> TryFrom<&'a RoomOrAliasId> for &'a RoomAliasId
impl<'a> TryFrom<&'a RoomOrAliasId> for &'a RoomAliasId
§fn try_from(id: &'a RoomOrAliasId) -> Result<&'a RoomAliasId, &'a RoomId>
fn try_from(id: &'a RoomOrAliasId) -> Result<&'a RoomAliasId, &'a RoomId>
§impl<'a> TryFrom<&'a RoomOrAliasId> for &'a RoomId
impl<'a> TryFrom<&'a RoomOrAliasId> for &'a RoomId
§type Error = &'a RoomAliasId
type Error = &'a RoomAliasId
§fn try_from(id: &'a RoomOrAliasId) -> Result<&'a RoomId, &'a RoomAliasId>
fn try_from(id: &'a RoomOrAliasId) -> Result<&'a RoomId, &'a RoomAliasId>
§impl<'a> TryFrom<&'a str> for &'a RoomOrAliasId
impl<'a> TryFrom<&'a str> for &'a RoomOrAliasId
§impl TryFrom<&str> for Box<RoomOrAliasId>
impl TryFrom<&str> for Box<RoomOrAliasId>
§impl TryFrom<String> for Box<RoomOrAliasId>
impl TryFrom<String> for Box<RoomOrAliasId>
impl Eq for RoomOrAliasId
impl StructuralEq for RoomOrAliasId
impl StructuralPartialEq for RoomOrAliasId
Auto Trait Implementations§
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
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.