From 0d8702b292a03b4846c51284f632fd9f5ba7c34d Mon Sep 17 00:00:00 2001 From: Devin R Date: Sun, 12 Apr 2020 08:21:23 -0400 Subject: [PATCH] rename get_message_events to room_messages --- src/async_client.rs | 2 +- src/lib.rs | 2 +- src/request_builder.rs | 18 +++++++++--------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/async_client.rs b/src/async_client.rs index 9d9635e0..7ef25b69 100644 --- a/src/async_client.rs +++ b/src/async_client.rs @@ -505,7 +505,7 @@ impl AsyncClient { /// # Arguments /// /// * request - The easiest way to create a `Request` is using the `GetMessageBuilder` - pub async fn get_message_events>( + pub async fn room_messages>( &mut self, request: R, ) -> Result { diff --git a/src/lib.rs b/src/lib.rs index 1e9412ca..0e00b83e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -51,6 +51,6 @@ pub use async_client::{AsyncClient, AsyncClientConfig, SyncSettings}; pub use base_client::Client; pub use event_emitter::EventEmitter; pub use models::Room; -pub use request_builder::{GetMessageBuilder, RoomBuilder}; +pub use request_builder::{RoomBuilder, RoomMessageBuilder}; pub(crate) const VERSION: &str = env!("CARGO_PKG_VERSION"); diff --git a/src/request_builder.rs b/src/request_builder.rs index 7eef70af..9cdebe88 100644 --- a/src/request_builder.rs +++ b/src/request_builder.rs @@ -175,7 +175,7 @@ impl Into for RoomBuilder { /// Create a builder for making get_message_event requests. #[derive(Clone, Default)] -pub struct GetMessageBuilder { +pub struct RoomMessageBuilder { /// The room to get events from. room_id: Option, /// The token to start returning events from. @@ -200,14 +200,14 @@ pub struct GetMessageBuilder { filter: Option, } -impl GetMessageBuilder { - /// Create a `GetMessageBuilder` builder to make a `get_message_events::Request`. +impl RoomMessageBuilder { + /// Create a `RoomMessageBuilder` builder to make a `get_message_events::Request`. /// /// The `room_id` and `from`` fields **need to be set** to create the request. /// /// # Examples /// ``` - /// # use matrix_sdk::{AsyncClient, GetMessageBuilder}; + /// # use matrix_sdk::{AsyncClient, RoomMessageBuilder}; /// # use matrix_sdk::api::r0::message::get_message_events::{self, Direction}; /// # use matrix_sdk::identifiers::RoomId; /// # use url::Url; @@ -218,12 +218,12 @@ impl GetMessageBuilder { /// # let last_sync_token = "".to_string();; /// let mut cli = AsyncClient::new(homeserver, None).unwrap(); /// - /// let mut bldr = GetMessageBuilder::new(); + /// let mut bldr = RoomMessageBuilder::new(); /// bldr.room_id(room_id) /// .from(last_sync_token) /// .direction(Direction::Forward); /// - /// cli.get_message_events(bldr).await.is_err(); + /// cli.room_messages(bldr).await.is_err(); /// # }) /// ``` pub fn new() -> Self { @@ -273,7 +273,7 @@ impl GetMessageBuilder { } } -impl Into for GetMessageBuilder { +impl Into for RoomMessageBuilder { fn into(self) -> get_message_events::Request { get_message_events::Request { room_id: self.room_id.expect("`room_id` and `from` need to be set"), @@ -362,7 +362,7 @@ mod test { device_id: "DEVICEID".to_owned(), }; - let mut bldr = GetMessageBuilder::new(); + let mut bldr = RoomMessageBuilder::new(); bldr.room_id(RoomId::try_from("!roomid:example.com").unwrap()) .from("t47429-4392820_219380_26003_2265".to_string()) .to("t4357353_219380_26003_2265".to_string()) @@ -372,6 +372,6 @@ mod test { // .filter(RoomEventFilter::default()); let mut cli = AsyncClient::new(homeserver, Some(session)).unwrap(); - assert!(cli.get_message_events(bldr).await.is_ok()); + assert!(cli.room_messages(bldr).await.is_ok()); } }