logo
#[repr(transparent)]
pub struct UserId(_);
Expand description

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(), "@carl:example.com");

Implementations

Creates a string slice from this UserId.

Creates a byte slice from this UserId.

Try parsing a &str into an OwnedUserId.

The same can also be done using FromStr, TryFrom or TryInto. This function is simply more constrained and thus useful in generic contexts.

Try parsing a &str into a Box<UserId>.

The same can also be done using FromStr, TryFrom or TryInto. This function is simply more constrained and thus useful in generic contexts.

Try parsing a &str into an Rc<UserId>.

Try parsing a &str into an Arc<UserId>.

Attempts to generate a UserId for the given origin server with a localpart consisting of 12 random ASCII characters.

Attempts to complete a user ID, by adding the colon + server name and @ prefix, if not present already.

This is a convenience function for the login API, where a user can supply either their full user ID or just the localpart. It only supports a valid user ID or a valid user ID localpart, not the localpart plus the @ prefix, or the localpart plus server name without the @ prefix.

Variation of parse_with_server_name that returns Rc<Self>.

Variation of parse_with_server_name that returns Arc<Self>.

Returns the user’s localpart.

Returns the server name of the user ID.

Whether this user ID is a historical one.

A historical user ID is one that doesn’t conform to the latest specification of the user ID grammar but is still accepted because it was previously allowed.

Create a matrix.to URI for this user ID.

Example
use ruma_common::user_id;

let message = format!(
    r#"Thanks for the update <a href="{link}">{display_name}</a>."#,
    link = user_id!("@jplatte:notareal.hs").matrix_to_uri(),
    display_name = "jplatte",
);

Create a matrix: URI for this user ID.

If chat is true, a click on the URI should start a direct message with the user.

Example
use ruma_common::user_id;

let message = format!(
    r#"Thanks for the update <a href="{link}">{display_name}</a>."#,
    link = user_id!("@jplatte:notareal.hs").matrix_uri(false),
    display_name = "jplatte",
);

Trait Implementations

Converts this type into a shared reference of the (usually inferred) input type.

Converts this type into a shared reference of the (usually inferred) input type.

Converts this type into a shared reference of the (usually inferred) input type.

Immutably borrows from an owned value. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

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

This method tests for !=.

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

This method tests for !=.

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

This method tests for !=.

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

This method tests for !=.

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

This method tests for !=.

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

This method tests for !=.

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

This method tests for !=.

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

This method tests for !=.

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

This method tests for !=.

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

This method tests for !=.

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

This method tests for !=.

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

This method tests for !=.

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

This method tests for !=.

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

This method tests for !=.

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

This method tests for !=.

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

This method tests for !=.

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

This method tests for !=.

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

This method tests for !=.

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

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Serialize this value into the given Serde serializer. Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Compare self to key and return true if they are equal.

Converts the given value to a String. Read more