docs(rust): Run the register event handler doc example
This commit is contained in:
parent
a7b83d9cd1
commit
804a941762
1 changed files with 14 additions and 9 deletions
|
@ -920,8 +920,10 @@ impl Client {
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```no_run
|
/// ```
|
||||||
/// # let client: matrix_sdk::Client = unimplemented!();
|
/// # use url::Url;
|
||||||
|
/// # let homeserver = Url::parse("http://localhost:8080").unwrap();
|
||||||
|
/// # let client = Client::new(homeserver).unwrap();
|
||||||
/// use matrix_sdk::{
|
/// use matrix_sdk::{
|
||||||
/// room::Room,
|
/// room::Room,
|
||||||
/// ruma::{
|
/// ruma::{
|
||||||
|
@ -940,18 +942,21 @@ impl Client {
|
||||||
/// # let _ = async {
|
/// # let _ = async {
|
||||||
/// client
|
/// client
|
||||||
/// .register_event_handler(
|
/// .register_event_handler(
|
||||||
/// |ev: SyncMessageEvent<MessageEventContent>, room: Room, client: Client| async move {
|
/// |ev: SyncMessageEvent<MessageEventContent>,
|
||||||
|
/// room: Room,
|
||||||
|
/// client: Client| async move {
|
||||||
/// // Common usage: Room event plus room and client.
|
/// // Common usage: Room event plus room and client.
|
||||||
/// },
|
/// },
|
||||||
/// )
|
/// )
|
||||||
/// .await
|
/// .await
|
||||||
/// .register_event_handler(|ev: SyncStateEvent<TopicEventContent>| async move {
|
/// .register_event_handler(
|
||||||
|
/// |ev: SyncStateEvent<TopicEventContent>| async move {
|
||||||
/// // Also possible: Omit any or all arguments after the first.
|
/// // Also possible: Omit any or all arguments after the first.
|
||||||
/// })
|
/// }
|
||||||
/// .await;
|
/// ).await;
|
||||||
///
|
///
|
||||||
/// // Custom events work exactly the same way, you just need to declare the content struct and
|
/// // Custom events work exactly the same way, you just need to declare
|
||||||
/// // use the EventContent derive macro on it.
|
/// // the content struct and use the EventContent derive macro on it.
|
||||||
/// #[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
|
/// #[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
|
||||||
/// #[ruma_event(type = "org.shiny_new_2fa.token", kind = Message)]
|
/// #[ruma_event(type = "org.shiny_new_2fa.token", kind = Message)]
|
||||||
/// struct TokenEventContent {
|
/// struct TokenEventContent {
|
||||||
|
|
Loading…
Reference in a new issue