diff --git a/crates/ruma-client-api/CHANGELOG.md b/crates/ruma-client-api/CHANGELOG.md index a0d6d49d..db0ec0cc 100644 --- a/crates/ruma-client-api/CHANGELOG.md +++ b/crates/ruma-client-api/CHANGELOG.md @@ -3,6 +3,7 @@ Improvements: * Add `From<&UserId>` and `From<&OwnedUserId>` implementations for `UserIdentifier` +* Add `UserIdentifier::email` constructor # 0.14.0 diff --git a/crates/ruma-client-api/src/uiaa.rs b/crates/ruma-client-api/src/uiaa.rs index 4b15157c..d81d5a31 100644 --- a/crates/ruma-client-api/src/uiaa.rs +++ b/crates/ruma-client-api/src/uiaa.rs @@ -590,6 +590,13 @@ pub enum UserIdentifier<'a> { }, } +impl<'a> UserIdentifier<'a> { + /// Creates a [`UserIdentifier::ThirdPartyId`] from an email address. + pub fn email(address: &'a str) -> Self { + Self::ThirdPartyId { address, medium: Medium::Email } + } +} + impl<'a> From<&'a UserId> for UserIdentifier<'a> { fn from(id: &'a UserId) -> Self { Self::UserIdOrLocalpart(id.as_str())