Update doc-tests
This commit is contained in:
parent
b2cb9a67b3
commit
098c1d767c
60
src/lib.rs
60
src/lib.rs
@ -6,21 +6,26 @@
|
|||||||
//! secure connections, and then logging in:
|
//! secure connections, and then logging in:
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! ```no_run
|
||||||
//! use futures::Future;
|
//! # #![feature(impl_trait_in_bindings)]
|
||||||
|
//! #![feature(async_await)]
|
||||||
//! use ruma_client::Client;
|
//! use ruma_client::Client;
|
||||||
//!
|
//!
|
||||||
//! let homeserver_url = "https://example.com".parse().unwrap();
|
//! let work = async {
|
||||||
//! let client = Client::https(homeserver_url, None).unwrap();
|
//! let homeserver_url = "https://example.com".parse().unwrap();
|
||||||
|
//! let client = Client::https(homeserver_url, None).unwrap();
|
||||||
//!
|
//!
|
||||||
//! let work = client
|
//! let session = client
|
||||||
//! .log_in("@alice:example.com".to_string(), "secret".to_string(), None)
|
//! .log_in("@alice:example.com".to_string(), "secret".to_string(), None)
|
||||||
//! .and_then(|session| {
|
//! .await?;
|
||||||
//! // You're now logged in! Write the session to a file if you want to restore it later.
|
//!
|
||||||
//! // Then start using the API!
|
//! // You're now logged in! Write the session to a file if you want to restore it later.
|
||||||
//! # Ok::<(), ruma_client::Error>(())
|
//! // Then start using the API!
|
||||||
//! });
|
//! # Ok(())
|
||||||
|
//! };
|
||||||
//!
|
//!
|
||||||
//! // Start `work` on a futures runtime...
|
//! // Start `work` on a futures runtime...
|
||||||
|
//! # let work_typehint: impl futures::future::TryFuture<Ok = (), Error = ruma_client::Error>
|
||||||
|
//! # = work;
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! You can also pass an existing session to the `Client` constructor to restore a previous session
|
//! You can also pass an existing session to the `Client` constructor to restore a previous session
|
||||||
@ -30,16 +35,18 @@
|
|||||||
//! events), use the `Client::sync`:
|
//! events), use the `Client::sync`:
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! ```no_run
|
||||||
//! # use futures::{Future, Stream};
|
//! # #![feature(async_await)]
|
||||||
|
//! # use futures::stream::{StreamExt as _, TryStreamExt as _};
|
||||||
//! # use ruma_client::Client;
|
//! # use ruma_client::Client;
|
||||||
//! # let homeserver_url = "https://example.com".parse().unwrap();
|
//! # let homeserver_url = "https://example.com".parse().unwrap();
|
||||||
//! # let client = Client::https(homeserver_url, None).unwrap();
|
//! # let client = Client::https(homeserver_url, None).unwrap();
|
||||||
//! let work = client.sync(None, None, true).map(|response| {
|
//! # async {
|
||||||
//! // Do something with the data in the response...
|
//! let mut sync_stream = Box::pin(client.sync(None, None, true));
|
||||||
//! # Ok::<(), ruma_client::Error>(())
|
//! while let Some(response) = sync_stream.try_next().await? {
|
||||||
//! });
|
//! // Do something with the data in the response...
|
||||||
//!
|
//! }
|
||||||
//! // Start `work` on a futures runtime...
|
//! # Result::<(), ruma_client::Error>::Ok(())
|
||||||
|
//! # };
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! The `Client` type also provides methods for registering a new account if you don't already have
|
//! The `Client` type also provides methods for registering a new account if you don't already have
|
||||||
@ -54,7 +61,7 @@
|
|||||||
//! For example:
|
//! For example:
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! ```no_run
|
||||||
//! # use futures::Future;
|
//! # #![feature(async_await)]
|
||||||
//! # use ruma_client::Client;
|
//! # use ruma_client::Client;
|
||||||
//! # let homeserver_url = "https://example.com".parse().unwrap();
|
//! # let homeserver_url = "https://example.com".parse().unwrap();
|
||||||
//! # let client = Client::https(homeserver_url, None).unwrap();
|
//! # let client = Client::https(homeserver_url, None).unwrap();
|
||||||
@ -63,16 +70,17 @@
|
|||||||
//! use ruma_client::api::r0::alias::get_alias;
|
//! use ruma_client::api::r0::alias::get_alias;
|
||||||
//! use ruma_identifiers::{RoomAliasId, RoomId};
|
//! use ruma_identifiers::{RoomAliasId, RoomId};
|
||||||
//!
|
//!
|
||||||
//! let request = get_alias::Request {
|
//! async {
|
||||||
//! room_alias: RoomAliasId::try_from("#example_room:example.com").unwrap(),
|
//! let response = client
|
||||||
//! };
|
//! .request(get_alias::Request {
|
||||||
|
//! room_alias: RoomAliasId::try_from("#example_room:example.com").unwrap(),
|
||||||
|
//! })
|
||||||
|
//! .await?;
|
||||||
//!
|
//!
|
||||||
//! let work = get_alias::call(client, request).and_then(|response| {
|
|
||||||
//! assert_eq!(response.room_id, RoomId::try_from("!n8f893n9:example.com").unwrap());
|
//! assert_eq!(response.room_id, RoomId::try_from("!n8f893n9:example.com").unwrap());
|
||||||
//! # Ok::<(), ruma_client::Error>(())
|
//! # Result::<(), ruma_client::Error>::Ok(())
|
||||||
//! });
|
//! }
|
||||||
//!
|
//! # ;
|
||||||
//! // Start `work` on a futures runtime...
|
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
#![feature(async_await, async_closure)]
|
#![feature(async_await, async_closure)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user