client-api: Add UserIdentifier::email

This commit is contained in:
Jonas Platte 2022-05-12 11:22:21 +02:00 committed by Jonas Platte
parent 0661078c17
commit 24c0a08b2c
2 changed files with 8 additions and 0 deletions

View File

@ -3,6 +3,7 @@
Improvements: Improvements:
* Add `From<&UserId>` and `From<&OwnedUserId>` implementations for `UserIdentifier` * Add `From<&UserId>` and `From<&OwnedUserId>` implementations for `UserIdentifier`
* Add `UserIdentifier::email` constructor
# 0.14.0 # 0.14.0

View File

@ -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> { impl<'a> From<&'a UserId> for UserIdentifier<'a> {
fn from(id: &'a UserId) -> Self { fn from(id: &'a UserId) -> Self {
Self::UserIdOrLocalpart(id.as_str()) Self::UserIdOrLocalpart(id.as_str())