client: Use http_client::Dummy for doctests

This commit is contained in:
Jonas Platte 2021-04-28 23:24:09 +02:00
parent a2b64df5d3
commit e3beb208e5
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67
2 changed files with 24 additions and 23 deletions

View File

@ -83,14 +83,14 @@ impl<C: HttpClient> Client<C> {
///
/// # Example:
///
/// ```ignore
/// ```no_run
/// use std::time::Duration;
///
/// # use ruma_client::Client;
/// # type MatrixClient = ruma_client::Client<ruma_client::http_client::Dummy>;
/// # 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(

View File

@ -4,15 +4,16 @@
//!
//! # 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;
//!
//! let work = async {
//! // type MatrixClient = ruma_client::Client<ruma_client::http_client::_>;
//! # type MatrixClient = ruma_client::Client<ruma_client::http_client::Dummy>;
//! # let work = async {
//! let homeserver_url = "https://example.com".parse().unwrap();
//! let client = Client::new(homeserver_url, None);
//! let client = MatrixClient::new(homeserver_url, None);
//!
//! let session = client
//! .log_in("@alice:example.com", "secret", None, None)
@ -20,20 +21,20 @@
//!
//! // 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(())
//! };
//! # 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<ruma_client::http_client::Dummy>;
//!
//! 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<ruma_client::http_client::Dummy>;
//! # 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::{