From e3beb208e5d1accbfde4aef2628a6dec36b41741 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Wed, 28 Apr 2021 23:24:09 +0200 Subject: [PATCH] client: Use http_client::Dummy for doctests --- ruma-client/src/client_api.rs | 6 ++--- ruma-client/src/lib.rs | 41 ++++++++++++++++++----------------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/ruma-client/src/client_api.rs b/ruma-client/src/client_api.rs index 033ee21a..54ac3b32 100644 --- a/ruma-client/src/client_api.rs +++ b/ruma-client/src/client_api.rs @@ -83,14 +83,14 @@ impl Client { /// /// # Example: /// - /// ```ignore + /// ```no_run /// use std::time::Duration; /// - /// # use ruma_client::Client; + /// # type MatrixClient = ruma_client::Client; /// # use ruma::presence::PresenceState; /// # use tokio_stream::{StreamExt as _}; /// # let homeserver_url = "https://example.com".parse().unwrap(); - /// # let client = Client::new(homeserver_url, None); + /// # let client = MatrixClient::new(homeserver_url, None); /// # let next_batch_token = String::new(); /// # async { /// let mut sync_stream = Box::pin(client.sync( diff --git a/ruma-client/src/lib.rs b/ruma-client/src/lib.rs index 38157ebf..fca567b0 100644 --- a/ruma-client/src/lib.rs +++ b/ruma-client/src/lib.rs @@ -4,36 +4,37 @@ //! //! # Usage //! -//! Begin by creating a `Client` type, usually using the `https` method for a client that supports -//! secure connections, and then logging in: +//! Begin by creating a `Client`, selecting one of the type aliases from `ruma_client::http_client` +//! for the generic parameter. For the client API, there are login and registration methods +//! provided for the client (feature `client-api`): //! //! ```ignore -//! use ruma_client::Client; +//! // type MatrixClient = ruma_client::Client; +//! # type MatrixClient = ruma_client::Client; +//! # let work = async { +//! let homeserver_url = "https://example.com".parse().unwrap(); +//! let client = MatrixClient::new(homeserver_url, None); //! -//! let work = async { -//! let homeserver_url = "https://example.com".parse().unwrap(); -//! let client = Client::new(homeserver_url, None); +//! let session = client +//! .log_in("@alice:example.com", "secret", None, None) +//! .await?; //! -//! let session = client -//! .log_in("@alice:example.com", "secret", None, None) -//! .await?; -//! -//! // You're now logged in! Write the session to a file if you want to restore it later. -//! // Then start using the API! -//! # Result::<(), ruma_client::Error<_>>::Ok(()) -//! }; +//! // You're now logged in! Write the session to a file if you want to restore it later. +//! // Then start using the API! +//! # Result::<(), ruma_client::Error<_, _>>::Ok(()) +//! # }; //! ``` //! //! You can also pass an existing access token to the `Client` constructor to restore a previous //! session rather than calling `log_in`. This can also be used to create a session for an //! application service that does not need to log in, but uses the access_token directly: //! -//! ```ignore -//! use ruma_client::Client; +//! ```no_run +//! # type MatrixClient = ruma_client::Client; //! //! let work = async { //! let homeserver_url = "https://example.com".parse().unwrap(); -//! let client = Client::new(homeserver_url, Some("as_access_token".into())); +//! let client = MatrixClient::new(homeserver_url, Some("as_access_token".into())); //! //! // make calls to the API //! }; @@ -48,10 +49,10 @@ //! //! For example: //! -//! ```ignore -//! # use ruma_client::Client; +//! ```no_run +//! # type MatrixClient = ruma_client::Client; //! # let homeserver_url = "https://example.com".parse().unwrap(); -//! # let client = Client::new(homeserver_url, None); +//! # let client = MatrixClient::new(homeserver_url, None); //! use std::convert::TryFrom; //! //! use ruma::{