Struct crackle_lib::RoomId
[−]#[repr(transparent)]pub struct RoomId(_);
Expand description
A Matrix room ID.
A RoomId
is generated randomly or converted from a string slice, and can be converted back
into a string as needed.
assert_eq!(<&RoomId>::try_from("!n8f893n9:example.com").unwrap(), "!n8f893n9:example.com");
Implementations
impl RoomId
impl RoomId
pub fn new(server_name: &ServerName) -> OwnedRoomId
pub fn new(server_name: &ServerName) -> OwnedRoomId
Attempts to generate a RoomId
for the given origin server with a localpart consisting of
18 random ASCII characters.
Fails if the given homeserver cannot be parsed as a valid host.
pub fn server_name(&self) -> &ServerName
pub fn server_name(&self) -> &ServerName
Returns the server name of the room ID.
pub fn matrix_to_uri<'a>(
&self,
via: impl IntoIterator<Item = &'a ServerName>
) -> MatrixToUri
pub fn matrix_to_uri<'a>(
&self,
via: impl IntoIterator<Item = &'a ServerName>
) -> MatrixToUri
Create a matrix.to
URI for this room ID.
Example
use ruma_common::{room_id, server_name};
assert_eq!(
room_id!("!somewhere:example.org")
.matrix_to_uri([&*server_name!("example.org"), &*server_name!("alt.example.org")])
.to_string(),
"https://matrix.to/#/%21somewhere%3Aexample.org?via=example.org&via=alt.example.org"
);
pub fn matrix_to_event_uri(&self, ev_id: &EventId) -> MatrixToUri
pub fn matrix_to_event_uri(&self, ev_id: &EventId) -> MatrixToUri
Create a matrix.to
URI for an event scoped under this room ID.
pub fn matrix_uri<'a>(
&self,
via: impl IntoIterator<Item = &'a ServerName>,
join: bool
) -> MatrixUri
pub fn matrix_uri<'a>(
&self,
via: impl IntoIterator<Item = &'a ServerName>,
join: bool
) -> MatrixUri
Create a matrix:
URI for this room ID.
If join
is true
, a click on the URI should join the room.
Example
use ruma_common::{room_id, server_name};
assert_eq!(
room_id!("!somewhere:example.org")
.matrix_uri([&*server_name!("example.org"), &*server_name!("alt.example.org")], true)
.to_string(),
"matrix:roomid/somewhere:example.org?via=example.org&via=alt.example.org&action=join"
);
pub fn matrix_event_uri<'a>(
&self,
ev_id: &EventId,
via: impl IntoIterator<Item = &'a ServerName>
) -> MatrixUri
pub fn matrix_event_uri<'a>(
&self,
ev_id: &EventId,
via: impl IntoIterator<Item = &'a ServerName>
) -> MatrixUri
Create a matrix:
URI for an event scoped under this room ID.
impl RoomId
impl RoomId
impl RoomId
impl RoomId
pub fn parse(s: impl AsRef<str>) -> Result<OwnedRoomId, Error>
pub fn parse(s: impl AsRef<str>) -> Result<OwnedRoomId, Error>
Try parsing a &str
into an OwnedRoomId
.
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, Global>>
) -> Result<Box<RoomId, Global>, Error>
pub fn parse_box(
s: impl AsRef<str> + Into<Box<str, Global>>
) -> Result<Box<RoomId, Global>, Error>
Try parsing a &str
into a Box<RoomId>
.
The same can also be done using FromStr
, TryFrom
or TryInto
.
This function is simply more constrained and thus useful in generic contexts.
Trait Implementations
impl AsRef<RoomId> for OwnedRoomId
impl AsRef<RoomId> for OwnedRoomId
impl Borrow<RoomId> for OwnedRoomId
impl Borrow<RoomId> for OwnedRoomId
impl<'_> From<&'_ RoomId> for OwnedRoomId
impl<'_> From<&'_ RoomId> for OwnedRoomId
fn from(id: &RoomId) -> OwnedRoomId
fn from(id: &RoomId) -> OwnedRoomId
Converts to this type from the input type.
impl Ord for RoomId
impl Ord for RoomId
impl<'_> PartialEq<&'_ RoomId> for OwnedRoomId
impl<'_> PartialEq<&'_ RoomId> for OwnedRoomId
impl PartialEq<OwnedRoomId> for RoomId
impl PartialEq<OwnedRoomId> for RoomId
impl<'_> PartialEq<OwnedRoomId> for &'_ RoomId
impl<'_> PartialEq<OwnedRoomId> for &'_ RoomId
impl PartialEq<RoomId> for OwnedRoomId
impl PartialEq<RoomId> for OwnedRoomId
impl PartialOrd<RoomId> for RoomId
impl PartialOrd<RoomId> for RoomId
fn partial_cmp(&self, other: &RoomId) -> Option<Ordering>
fn partial_cmp(&self, other: &RoomId) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Serialize for RoomId
impl Serialize for RoomId
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
impl ToOwned for RoomId
impl ToOwned for RoomId
type Owned = OwnedRoomId
type Owned = OwnedRoomId
The resulting type after obtaining ownership.
fn to_owned(&self) -> <RoomId as ToOwned>::Owned
fn to_owned(&self) -> <RoomId as ToOwned>::Owned
Creates owned data from borrowed data, usually by cloning. Read more
sourcefn clone_into(&self, target: &mut Self::Owned)
fn clone_into(&self, target: &mut Self::Owned)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<'a> TryFrom<&'a RoomOrAliasId> for &'a RoomId
impl<'a> TryFrom<&'a RoomOrAliasId> for &'a RoomId
type Error = &'a RoomAliasId
type Error = &'a RoomAliasId
The type returned in the event of a conversion error.
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.
impl Eq for RoomId
impl StructuralEq for RoomId
impl StructuralPartialEq for RoomId
Auto Trait Implementations
impl RefUnwindSafe for RoomId
impl Send for RoomId
impl !Sized for RoomId
impl Sync for RoomId
impl Unpin for RoomId
impl UnwindSafe for RoomId
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.