client: Fix doctests by not compiling them
… and move the sync example to sync's docs.
This commit is contained in:
parent
c692d18797
commit
e94e2e7b2b
@ -80,6 +80,31 @@ impl<C: HttpClient> Client<C> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Convenience method that represents repeated calls to the sync_events endpoint as a stream.
|
/// Convenience method that represents repeated calls to the sync_events endpoint as a stream.
|
||||||
|
///
|
||||||
|
/// # Example:
|
||||||
|
///
|
||||||
|
/// ```ignore
|
||||||
|
/// use std::time::Duration;
|
||||||
|
///
|
||||||
|
/// # use 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 next_batch_token = String::new();
|
||||||
|
/// # async {
|
||||||
|
/// let mut sync_stream = Box::pin(client.sync(
|
||||||
|
/// None,
|
||||||
|
/// next_batch_token,
|
||||||
|
/// &PresenceState::Online,
|
||||||
|
/// Some(Duration::from_secs(30)),
|
||||||
|
/// ));
|
||||||
|
/// while let Some(response) = sync_stream.try_next().await? {
|
||||||
|
/// // Do something with the data in the response...
|
||||||
|
/// }
|
||||||
|
/// # Result::<(), ruma_client::Error<_, _>>::Ok(())
|
||||||
|
/// # };
|
||||||
|
/// ```
|
||||||
pub fn sync<'a>(
|
pub fn sync<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
filter: Option<&'a sync_events::Filter<'a>>,
|
filter: Option<&'a sync_events::Filter<'a>>,
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
//! session rather than calling `log_in`. This can also be used to create a session for an
|
//! 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:
|
//! application service that does not need to log in, but uses the access_token directly:
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! ```ignore
|
||||||
//! use ruma_client::Client;
|
//! use ruma_client::Client;
|
||||||
//!
|
//!
|
||||||
//! let work = async {
|
//! let work = async {
|
||||||
@ -39,32 +39,6 @@
|
|||||||
//! };
|
//! };
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! For the standard use case of synchronizing with the homeserver (i.e. getting all the latest
|
|
||||||
//! events), use the `Client::sync` method:
|
|
||||||
//!
|
|
||||||
//! ```ignore
|
|
||||||
//! use std::time::Duration;
|
|
||||||
//!
|
|
||||||
//! # use 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 next_batch_token = String::new();
|
|
||||||
//! # async {
|
|
||||||
//! let mut sync_stream = Box::pin(client.sync(
|
|
||||||
//! None,
|
|
||||||
//! next_batch_token,
|
|
||||||
//! &PresenceState::Online,
|
|
||||||
//! Some(Duration::from_secs(30)),
|
|
||||||
//! ));
|
|
||||||
//! while let Some(response) = sync_stream.try_next().await? {
|
|
||||||
//! // Do something with the data in the response...
|
|
||||||
//! }
|
|
||||||
//! # 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
|
||||||
//! one with the given homeserver.
|
//! one with the given homeserver.
|
||||||
//!
|
//!
|
||||||
@ -74,7 +48,7 @@
|
|||||||
//!
|
//!
|
||||||
//! For example:
|
//! For example:
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! ```ignore
|
||||||
//! # 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::new(homeserver_url, None);
|
//! # let client = Client::new(homeserver_url, None);
|
||||||
@ -87,11 +61,11 @@
|
|||||||
//!
|
//!
|
||||||
//! async {
|
//! async {
|
||||||
//! let response = client
|
//! let response = client
|
||||||
//! .request(get_alias::Request::new(&room_alias_id!("#example_room:example.com")))
|
//! .send_request(get_alias::Request::new(&room_alias_id!("#example_room:example.com")))
|
||||||
//! .await?;
|
//! .await?;
|
||||||
//!
|
//!
|
||||||
//! assert_eq!(response.room_id, room_id!("!n8f893n9:example.com"));
|
//! assert_eq!(response.room_id, room_id!("!n8f893n9:example.com"));
|
||||||
//! # Result::<(), ruma_client::Error<_>>::Ok(())
|
//! # Result::<(), ruma_client::Error<_, _>>::Ok(())
|
||||||
//! }
|
//! }
|
||||||
//! # ;
|
//! # ;
|
||||||
//! ```
|
//! ```
|
||||||
|
Loading…
x
Reference in New Issue
Block a user