client-api: Add From impls for UserIdentifier
This commit is contained in:
parent
af07bfb8f4
commit
0661078c17
@ -1,5 +1,9 @@
|
||||
# [unreleased]
|
||||
|
||||
Improvements:
|
||||
|
||||
* Add `From<&UserId>` and `From<&OwnedUserId>` implementations for `UserIdentifier`
|
||||
|
||||
# 0.14.0
|
||||
|
||||
Bug fixes:
|
||||
|
@ -12,7 +12,7 @@ use ruma_common::{
|
||||
},
|
||||
serde::{from_raw_json_value, Incoming, JsonObject, StringEnum},
|
||||
thirdparty::Medium,
|
||||
ClientSecret, OwnedSessionId,
|
||||
ClientSecret, OwnedSessionId, OwnedUserId, UserId,
|
||||
};
|
||||
use serde::{
|
||||
de::{self, DeserializeOwned},
|
||||
@ -590,6 +590,18 @@ pub enum UserIdentifier<'a> {
|
||||
},
|
||||
}
|
||||
|
||||
impl<'a> From<&'a UserId> for UserIdentifier<'a> {
|
||||
fn from(id: &'a UserId) -> Self {
|
||||
Self::UserIdOrLocalpart(id.as_str())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a OwnedUserId> for UserIdentifier<'a> {
|
||||
fn from(id: &'a OwnedUserId) -> Self {
|
||||
Self::UserIdOrLocalpart(id.as_str())
|
||||
}
|
||||
}
|
||||
|
||||
impl IncomingUserIdentifier {
|
||||
pub(crate) fn to_outgoing(&self) -> UserIdentifier<'_> {
|
||||
match self {
|
||||
|
Loading…
x
Reference in New Issue
Block a user