Struct ruma_identifiers::UserId
[−]
[src]
pub struct UserId { /* fields omitted */ }
A Matrix user ID.
A UserId
is generated randomly or converted from a string slice, and can be converted back
into a string as needed.
assert_eq!( UserId::try_from("@carl:example.com").unwrap().to_string(), "@carl:example.com" );
Methods
impl UserId
[src]
fn new(server_name: &str) -> Result<Self, Error>
Attempts to generate a UserId
for the given origin server with a localpart consisting of
12 random ASCII characters.
Fails if the given origin server name cannot be parsed as a valid host.
fn hostname(&self) -> &Host
Returns a Host
for the user ID, containing the server name (minus the port) of the
originating homeserver.
The host can be either a domain name, an IPv4 address, or an IPv6 address.
fn localpart(&self) -> &str
Returns the user's localpart.
fn port(&self) -> u16
Returns the port the originating homeserver can be accessed on.
Trait Implementations
impl Clone for UserId
[src]
fn clone(&self) -> UserId
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Debug for UserId
[src]
impl Eq for UserId
[src]
impl Hash for UserId
[src]
fn hash<__H: Hasher>(&self, __arg_0: &mut __H)
Feeds this value into the state given, updating the hasher as necessary.
fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher
1.3.0
Feeds a slice of this type into the state provided.
impl PartialEq for UserId
[src]
fn eq(&self, __arg_0: &UserId) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &UserId) -> bool
This method tests for !=
.
impl Display for UserId
[src]
fn fmt(&self, f: &mut Formatter) -> FmtResult
Formats the value using the given formatter. Read more
impl Serialize for UserId
[src]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer
Serialize this value into the given Serde serializer. Read more
impl Deserialize for UserId
[src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: Deserializer
Deserialize this value from the given Serde deserializer. Read more
impl<'a> TryFrom<&'a str> for UserId
[src]
type Error = Error
try_from
)The type returned in the event of a conversion error.
fn try_from(user_id: &'a str) -> Result<UserId, Error>
try_from
)Attempts to create a new Matrix user ID from a string representation.
The string must include the leading @ sigil, the localpart, a literal colon, and a valid server name.