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