From 669a3f22d24f96c18e5352bc2b53fc70919bd5b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Sun, 5 Jul 2020 16:47:38 +0200 Subject: [PATCH] matrix-sdk: Allow getting the user id from the client. --- matrix_sdk/src/client.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/matrix_sdk/src/client.rs b/matrix_sdk/src/client.rs index be083ad1..7e0d7428 100644 --- a/matrix_sdk/src/client.rs +++ b/matrix_sdk/src/client.rs @@ -346,6 +346,12 @@ impl Client { &self.homeserver } + /// Get the user id of the current owner of the client. + pub async fn user_id(&self) -> Option { + let session = self.base_client.session().read().await; + session.as_ref().cloned().map(|s| s.user_id) + } + /// Add `EventEmitter` to `Client`. /// /// The methods of `EventEmitter` are called when the respective `RoomEvents` occur.