From e16b7f9c44df77aa258820d7220089830b6ef6dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Tue, 6 Oct 2020 12:01:47 +0200 Subject: [PATCH] matrix-sdk: Add an example for the login method. --- matrix_sdk/src/client.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/matrix_sdk/src/client.rs b/matrix_sdk/src/client.rs index 15279756..6f00ab2b 100644 --- a/matrix_sdk/src/client.rs +++ b/matrix_sdk/src/client.rs @@ -491,6 +491,25 @@ impl Client { /// device_id from a previous login call. Note that this should be done /// only if the client also holds the encryption keys for this device. /// + /// # Example + /// ```no_run + /// # use std::convert::TryFrom; + /// # use matrix_sdk::Client; + /// # use matrix_sdk::identifiers::DeviceId; + /// # use matrix_sdk_common::assign; + /// # use futures::executor::block_on; + /// # use url::Url; + /// # let homeserver = Url::parse("http://example.com").unwrap(); + /// # block_on(async { + /// let client = Client::new(homeserver).unwrap(); + /// let user = "example"; + /// let response = client.login(user, "wordpass", None, Some("My bot")).await; + /// + /// println!("Logged in as {}, got device_id {} and access_token {}", + /// user, response.device_id, response.access_token); + /// # }) + /// ``` + /// /// [`restore_login`]: #method.restore_login #[instrument(skip(password))] pub async fn login(