From bdd1fb2c19c660b1c35cba4f0ab325d091c84c38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Fri, 10 Apr 2020 11:53:07 +0200 Subject: [PATCH] async_client: Expand the docs for the message sending method. --- src/async_client.rs | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/async_client.rs b/src/async_client.rs index e5c00be6..9ce12c68 100644 --- a/src/async_client.rs +++ b/src/async_client.rs @@ -626,16 +626,46 @@ impl AsyncClient { /// /// Returns the parsed response from the server. /// + /// If the encryption feature is enabled this method will transparently + /// encrypt the room message if the given room is encrypted. + /// /// # Arguments /// /// * `room_id` - The id of the room that should receive the message. /// - /// * `data` - The content of the message. + /// * `content` - The content of the message event. + /// + /// # Example + /// ```no_run + /// # use matrix_sdk::Room; + /// # use std::sync::{Arc, RwLock}; + /// # use matrix_sdk::{AsyncClient, SyncSettings}; + /// # use url::Url; + /// # use futures::executor::block_on; + /// # use ruma_identifiers::RoomId; + /// # use std::convert::TryFrom; + /// use matrix_sdk::events::room::message::{MessageEventContent, TextMessageEventContent}; + /// # block_on(async { + /// # let homeserver = Url::parse("http://localhost:8080").unwrap(); + /// # let mut client = AsyncClient::new(homeserver, None).unwrap(); + /// # let room_id = RoomId::try_from("!test:localhost").unwrap(); + /// + /// let content = MessageEventContent::Text(TextMessageEventContent { + /// body: "Hello world".to_owned(), + /// format: None, + /// formatted_body: None, + /// relates_to: None, + /// }); + /// + /// client.room_send(&room_id, content).await.unwrap(); + /// }) + /// ``` pub async fn room_send( &mut self, room_id: &RoomId, - mut content: MessageEventContent, + #[allow(unused_mut)] mut content: MessageEventContent, ) -> Result { + #[allow(unused_mut)] let mut event_type = EventType::RoomMessage; #[cfg(feature = "encryption")]