diff --git a/Cargo.toml b/Cargo.toml index 671043d6..c9b4d43d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,9 +21,9 @@ futures-util = "0.3.4" http = "0.2.1" hyper = "0.13.5" hyper-tls = { version = "0.4.1", optional = true } -ruma-api = "0.16.0-rc.2" +ruma-api = "0.16.0-rc.3" ruma-client-api = "0.8.0-rc.4" -ruma-events = "0.20.0" +ruma-events = "0.21.0-beta.1" ruma-identifiers = "0.16.0" serde = { version = "1.0.106", features = ["derive"] } serde_json = "1.0.51" diff --git a/examples/hello_world.rs b/examples/hello_world.rs index 6667e8c4..33020285 100644 --- a/examples/hello_world.rs +++ b/examples/hello_world.rs @@ -41,7 +41,8 @@ async fn hello_world(homeserver_url: Url, room: String) -> anyhow::Result<()> { format: None, formatted_body: None, relates_to: None, - }), + }) + .into(), }) .await?; diff --git a/examples/message_log.rs b/examples/message_log.rs index f8ef4c18..8971d43a 100644 --- a/examples/message_log.rs +++ b/examples/message_log.rs @@ -41,7 +41,7 @@ async fn log_messages( .timeline .events .into_iter() - .flat_map(|r| r.into_result()) + .flat_map(|r| r.deserialize()) { // Filter out the text messages if let RoomEvent::RoomMessage(MessageEvent { diff --git a/src/lib.rs b/src/lib.rs index 7f8f6399..4ad8fece 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -119,10 +119,7 @@ use http::Response as HttpResponse; use hyper::{client::HttpConnector, Client as HyperClient, Uri}; #[cfg(feature = "hyper-tls")] use hyper_tls::HttpsConnector; -use ruma_api::{ - error::{FromHttpRequestError, FromHttpResponseError}, - Endpoint, Outgoing, -}; +use ruma_api::Endpoint; use ruma_identifiers::DeviceId; use std::collections::BTreeMap; use url::Url; @@ -334,9 +331,8 @@ where since: Option, set_presence: api::r0::sync::sync_events::SetPresence, timeout: Option, - ) -> impl Stream>> - + TryStream> - { + ) -> impl Stream>> + + TryStream> { use api::r0::sync::sync_events; let client = self.clone(); @@ -365,16 +361,7 @@ where pub fn request( &self, request: Request, - ) -> impl Future< - Output = Result<::Incoming, Error>, - > - // We need to duplicate Endpoint's where clauses because the compiler is not smart enough yet. - // See https://github.com/rust-lang/rust/issues/54149 - where - Request::Incoming: TryFrom>, Error = FromHttpRequestError>, - ::Incoming: - TryFrom>, Error = FromHttpResponseError>, - { + ) -> impl Future>> { self.request_with_url_params(request, None) } @@ -383,16 +370,7 @@ where &self, request: Request, params: Option>, - ) -> impl Future< - Output = Result<::Incoming, Error>, - > - // We need to duplicate Endpoint's where clauses because the compiler is not smart enough yet. - // See https://github.com/rust-lang/rust/issues/54149 - where - Request::Incoming: TryFrom>, Error = FromHttpRequestError>, - ::Incoming: - TryFrom>, Error = FromHttpResponseError>, - { + ) -> impl Future>> { let client = self.0.clone(); let mut url = client.homeserver_url.clone(); @@ -432,9 +410,7 @@ where let full_body = hyper::body::to_bytes(body).await?; let full_response = HttpResponse::from_parts(head, full_body.as_ref().to_owned()); - Ok(::Incoming::try_from( - full_response, - )?) + Ok(Request::Response::try_from(full_response)?) } } }