diff --git a/crates/ruma-client/CHANGELOG.md b/crates/ruma-client/CHANGELOG.md index c4ecf1b6..62375b3e 100644 --- a/crates/ruma-client/CHANGELOG.md +++ b/crates/ruma-client/CHANGELOG.md @@ -1,5 +1,9 @@ # [unreleased] +Breaking changes: + +- Remove `isahc` feature + Improvements: - Add `error_kind` accessor method to `Error` diff --git a/crates/ruma-client/Cargo.toml b/crates/ruma-client/Cargo.toml index 78c53a83..f26f7665 100644 --- a/crates/ruma-client/Cargo.toml +++ b/crates/ruma-client/Cargo.toml @@ -22,7 +22,6 @@ client-api = ["dep:as_variant", "dep:ruma-client-api"] hyper = ["dep:hyper"] hyper-native-tls = ["hyper", "dep:hyper-tls"] hyper-rustls = ["hyper", "dep:hyper-rustls"] -isahc = ["dep:isahc", "futures-lite"] reqwest = ["dep:reqwest"] reqwest-native-tls = ["reqwest", "reqwest?/native-tls"] reqwest-native-tls-alpn = ["reqwest", "reqwest?/native-tls-alpn"] @@ -37,12 +36,10 @@ assign = { workspace = true } async-stream = "0.3.0" bytes = "1.0.1" futures-core = "0.3.8" -futures-lite = { version = "1.11.3", optional = true } http = { workspace = true } hyper = { version = "0.14.2", optional = true, features = ["client", "http1", "http2", "tcp"] } hyper-rustls = { version = "0.24.0", optional = true, default-features = false } hyper-tls = { version = "0.5.0", optional = true } -isahc = { version = "1.3.1", optional = true } reqwest = { version = "0.11.4", optional = true, default-features = false } ruma-client-api = { workspace = true, optional = true, features = ["client"] } ruma-common = { workspace = true, features = ["api"] } diff --git a/crates/ruma-client/src/http_client.rs b/crates/ruma-client/src/http_client.rs index 6c172807..ca121634 100644 --- a/crates/ruma-client/src/http_client.rs +++ b/crates/ruma-client/src/http_client.rs @@ -13,8 +13,6 @@ use crate::{add_user_id_to_query, ResponseError, ResponseResult}; #[cfg(feature = "hyper")] mod hyper; -#[cfg(feature = "isahc")] -mod isahc; #[cfg(feature = "reqwest")] mod reqwest; @@ -24,8 +22,6 @@ pub use self::hyper::Hyper; pub use self::hyper::HyperNativeTls; #[cfg(feature = "hyper-rustls")] pub use self::hyper::HyperRustls; -#[cfg(feature = "isahc")] -pub use self::isahc::Isahc; #[cfg(feature = "reqwest")] pub use self::reqwest::Reqwest; diff --git a/crates/ruma-client/src/http_client/isahc.rs b/crates/ruma-client/src/http_client/isahc.rs deleted file mode 100644 index ef8cd60f..00000000 --- a/crates/ruma-client/src/http_client/isahc.rs +++ /dev/null @@ -1,22 +0,0 @@ -use futures_lite::AsyncReadExt; - -use super::HttpClient; - -/// The `isahc` crate's `HttpClient`. -pub type Isahc = isahc::HttpClient; - -impl HttpClient for Isahc { - type RequestBody = Vec; - type ResponseBody = Vec; - type Error = isahc::Error; - - async fn send_http_request( - &self, - req: http::Request>, - ) -> Result>, isahc::Error> { - let (head, mut body) = self.send_async(req).await?.into_parts(); - let mut full_body = Vec::new(); - body.read_to_end(&mut full_body).await?; - Ok(http::Response::from_parts(head, full_body)) - } -} diff --git a/crates/ruma-client/src/lib.rs b/crates/ruma-client/src/lib.rs index 2fcf4122..a39f3d58 100644 --- a/crates/ruma-client/src/lib.rs +++ b/crates/ruma-client/src/lib.rs @@ -84,7 +84,6 @@ //! * `hyper` //! * `hyper-native-tls` //! * `hyper-rustls` -//! * `isahc` //! * `reqwest` – if you use the `reqwest` library already, activate this feature and configure the //! TLS backend on `reqwest` directly. If you want to use `reqwest` but don't depend on it //! already, use one of the sub-features instead. For details on the meaning of these, see diff --git a/crates/ruma/Cargo.toml b/crates/ruma/Cargo.toml index ca78a87c..a296bcb9 100644 --- a/crates/ruma/Cargo.toml +++ b/crates/ruma/Cargo.toml @@ -28,7 +28,6 @@ state-res = ["dep:ruma-state-res"] client-ext-client-api = ["client", "ruma-client?/client-api"] client-hyper = ["client", "ruma-client?/hyper"] client-hyper-native-tls = ["client", "ruma-client?/hyper-native-tls"] -client-isahc = ["client", "ruma-client?/isahc"] client-reqwest = ["client", "ruma-client?/reqwest"] client-reqwest-native-tls = ["client", "ruma-client?/reqwest-native-tls"] client-reqwest-native-tls-vendored = ["client", "ruma-client?/reqwest-native-tls-vendored"] diff --git a/examples/hello_isahc/Cargo.toml b/examples/hello_isahc/Cargo.toml deleted file mode 100644 index f8c1c5ce..00000000 --- a/examples/hello_isahc/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "hello_isahc" -version = "0.1.0" -edition = "2021" -publish = false - -[dependencies] -ruma = { version = "0.9.4", path = "../../crates/ruma", features = ["client-api-c", "client-ext-client-api", "client-isahc", "rand"] } - -anyhow = "1.0.37" -isahc = "1.3.1" -tokio = { version = "1.0.1", features = ["macros", "rt"] } diff --git a/examples/hello_isahc/README.md b/examples/hello_isahc/README.md deleted file mode 100644 index 17060116..00000000 --- a/examples/hello_isahc/README.md +++ /dev/null @@ -1,13 +0,0 @@ -Same as the [hello_world](../hello_world) example, but using the -[isahc](https://crates.io/crates/isahc) HTTP client (a Rust wrapper around libcurl). - -# Usage - -You will need to use an existing account on a homeserver that allows login with -a password. - -In this folder, you can run it with this command: - -```shell -cargo run -``` diff --git a/examples/hello_isahc/src/main.rs b/examples/hello_isahc/src/main.rs deleted file mode 100644 index f7749225..00000000 --- a/examples/hello_isahc/src/main.rs +++ /dev/null @@ -1,48 +0,0 @@ -use std::{env, process::exit}; - -use ruma::{ - api::client::{alias::get_alias, membership::join_room_by_id, message::send_message_event}, - events::room::message::RoomMessageEventContent, - OwnedRoomAliasId, TransactionId, -}; - -async fn hello_world( - homeserver_url: String, - username: &str, - password: &str, - room_alias: OwnedRoomAliasId, -) -> anyhow::Result<()> { - let http_client = isahc::HttpClient::new()?; - let client = - ruma::Client::builder().homeserver_url(homeserver_url).http_client(http_client).await?; - client.log_in(username, password, None, Some("ruma-example-client")).await?; - - let room_id = client.send_request(get_alias::v3::Request::new(room_alias)).await?.room_id; - client.send_request(join_room_by_id::v3::Request::new(room_id.clone())).await?; - client - .send_request(send_message_event::v3::Request::new( - room_id, - TransactionId::new(), - &RoomMessageEventContent::text_plain("Hello World!"), - )?) - .await?; - - Ok(()) -} - -#[tokio::main(flavor = "current_thread")] -async fn main() -> anyhow::Result<()> { - let (homeserver_url, username, password, room) = - match (env::args().nth(1), env::args().nth(2), env::args().nth(3), env::args().nth(4)) { - (Some(a), Some(b), Some(c), Some(d)) => (a, b, c, d), - _ => { - eprintln!( - "Usage: {} ", - env::args().next().unwrap() - ); - exit(1) - } - }; - - hello_world(homeserver_url, &username, &password, room.try_into()?).await -}