Skip to content

Commit 8665a8d

Browse files
authored
Use ruma instead of subcrates
Since this is not part of ruma anymore, we can use it.
1 parent 80cafb1 commit 8665a8d

File tree

6 files changed

+45
-40
lines changed

6 files changed

+45
-40
lines changed

Cargo.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ rust-version = "1.81"
1515
all-features = true
1616

1717
[features]
18-
client-api = ["dep:as_variant", "dep:ruma-client-api"]
18+
client-api = ["dep:as_variant", "ruma/client-api-c"]
1919

2020
# HTTP clients
2121
hyper = ["dep:http-body-util", "dep:hyper", "dep:hyper-util"]
@@ -42,13 +42,12 @@ hyper-rustls = { version = "0.27.1", optional = true, default-features = false }
4242
hyper-tls = { version = "0.6.0", optional = true }
4343
hyper-util = { version = "0.1.3", optional = true, features = ["client-legacy", "http1", "http2", "tokio"] }
4444
reqwest = { version = "0.12.4", optional = true, default-features = false }
45-
ruma-client-api = { version = "0.20.1", optional = true, features = ["client"] }
46-
ruma-common = { version = "0.15.1", features = ["api"] }
45+
ruma = { version = "0.12.1", features = ["api"] }
4746
serde_html_form = "0.2.0"
4847
tracing = { version = "0.1.30", default-features = false, features = ["std"] }
4948

5049
[dev-dependencies]
51-
ruma-client-api = { version = "0.20.1", features = ["client"] }
50+
ruma = { version = "0.12.1", features = ["client-api-c"] }
5251
tokio-stream = "0.1.8"
5352

5453
[lints.rust]

src/client.rs

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@ use std::{
66
use assign::assign;
77
use async_stream::try_stream;
88
use futures_core::stream::Stream;
9-
use ruma_client_api::{
10-
account::register::{self, RegistrationKind},
11-
session::login::{self, v3::LoginInfo},
12-
sync::sync_events,
13-
uiaa::UserIdentifier,
14-
};
15-
use ruma_common::{
16-
api::{MatrixVersion, OutgoingRequest, SendAccessToken},
9+
use ruma::{
10+
api::{
11+
client::{
12+
account::register::{self, RegistrationKind},
13+
session::login::{self, v3::LoginInfo},
14+
sync::sync_events,
15+
uiaa::UserIdentifier,
16+
},
17+
MatrixVersion, OutgoingRequest, SendAccessToken,
18+
},
1719
presence::PresenceState,
1820
DeviceId, UserId,
1921
};
@@ -117,7 +119,7 @@ impl<C: HttpClient> Client<C> {
117119
password: &str,
118120
device_id: Option<&DeviceId>,
119121
initial_device_display_name: Option<&str>,
120-
) -> Result<login::v3::Response, Error<C::Error, ruma_client_api::Error>> {
122+
) -> Result<login::v3::Response, Error<C::Error, ruma::api::client::Error>> {
121123
let login_info = LoginInfo::Password(login::v3::Password::new(
122124
UserIdentifier::UserIdOrLocalpart(user.to_owned()),
123125
password.to_owned(),
@@ -140,7 +142,8 @@ impl<C: HttpClient> Client<C> {
140142
/// returned by the endpoint in this client, in addition to returning it.
141143
pub async fn register_guest(
142144
&self,
143-
) -> Result<register::v3::Response, Error<C::Error, ruma_client_api::uiaa::UiaaResponse>> {
145+
) -> Result<register::v3::Response, Error<C::Error, ruma::api::client::uiaa::UiaaResponse>>
146+
{
144147
let response = self
145148
.send_request(assign!(register::v3::Request::new(), { kind: RegistrationKind::Guest }))
146149
.await?;
@@ -161,7 +164,8 @@ impl<C: HttpClient> Client<C> {
161164
&self,
162165
username: Option<&str>,
163166
password: &str,
164-
) -> Result<register::v3::Response, Error<C::Error, ruma_client_api::uiaa::UiaaResponse>> {
167+
) -> Result<register::v3::Response, Error<C::Error, ruma::api::client::uiaa::UiaaResponse>>
168+
{
165169
let response = self
166170
.send_request(assign!(register::v3::Request::new(), {
167171
username: username.map(ToOwned::to_owned),
@@ -181,7 +185,7 @@ impl<C: HttpClient> Client<C> {
181185
/// ```no_run
182186
/// use std::time::Duration;
183187
///
184-
/// # use ruma_common::presence::PresenceState;
188+
/// # use ruma::presence::PresenceState;
185189
/// # use tokio_stream::{StreamExt as _};
186190
/// # let homeserver_url = "https://example.com".to_owned();
187191
/// # async {
@@ -208,8 +212,9 @@ impl<C: HttpClient> Client<C> {
208212
mut since: String,
209213
set_presence: PresenceState,
210214
timeout: Option<Duration>,
211-
) -> impl Stream<Item = Result<sync_events::v3::Response, Error<C::Error, ruma_client_api::Error>>>
212-
+ '_ {
215+
) -> impl Stream<
216+
Item = Result<sync_events::v3::Response, Error<C::Error, ruma::api::client::Error>>,
217+
> + '_ {
213218
try_stream! {
214219
loop {
215220
let response = self

src/client/builder.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::sync::{Arc, Mutex};
22

3-
use ruma_client_api::discovery::get_supported_versions;
4-
use ruma_common::api::{MatrixVersion, SendAccessToken};
3+
use ruma::api::{client::discovery::get_supported_versions, MatrixVersion, SendAccessToken};
54

65
use super::{Client, ClientData};
76
use crate::{DefaultConstructibleHttpClient, Error, HttpClient, HttpClientExt};
@@ -48,7 +47,7 @@ impl ClientBuilder {
4847
/// Unless the supported Matrix versions were manually set via
4948
/// [`supported_matrix_versions`][Self::supported_matrix_versions], this will do a
5049
/// [`get_supported_versions`] request to find out about the supported versions.
51-
pub async fn build<C>(self) -> Result<Client<C>, Error<C::Error, ruma_client_api::Error>>
50+
pub async fn build<C>(self) -> Result<Client<C>, Error<C::Error, ruma::api::client::Error>>
5251
where
5352
C: DefaultConstructibleHttpClient,
5453
{
@@ -63,7 +62,7 @@ impl ClientBuilder {
6362
pub async fn http_client<C>(
6463
self,
6564
http_client: C,
66-
) -> Result<Client<C>, Error<C::Error, ruma_client_api::Error>>
65+
) -> Result<Client<C>, Error<C::Error, ruma::api::client::Error>>
6766
where
6867
C: HttpClient,
6968
{

src/error.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use std::fmt::{self, Debug, Display, Formatter};
44

5-
use ruma_common::api::error::{FromHttpResponseError, IntoHttpError};
5+
use ruma::api::error::{FromHttpResponseError, IntoHttpError};
66

77
/// An error that can occur during client operations.
88
#[derive(Debug)]
@@ -25,12 +25,12 @@ pub enum Error<E, F> {
2525
}
2626

2727
#[cfg(feature = "client-api")]
28-
impl<E> Error<E, ruma_client_api::Error> {
28+
impl<E> Error<E, ruma::api::client::Error> {
2929
/// If `self` is a server error in the `errcode` + `error` format expected
3030
/// for client-server API endpoints, returns the error kind (`errcode`).
31-
pub fn error_kind(&self) -> Option<&ruma_client_api::error::ErrorKind> {
31+
pub fn error_kind(&self) -> Option<&ruma::api::client::error::ErrorKind> {
3232
use as_variant::as_variant;
33-
use ruma_client_api::error::FromHttpResponseErrorExt as _;
33+
use ruma::api::client::error::FromHttpResponseErrorExt as _;
3434

3535
as_variant!(self, Self::FromHttpResponse)?.error_kind()
3636
}

src/http_client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use std::{future::Future, pin::Pin};
55

66
use bytes::BufMut;
7-
use ruma_common::{
7+
use ruma::{
88
api::{MatrixVersion, OutgoingRequest, SendAccessToken},
99
UserId,
1010
};

src/lib.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@
88
//! for the generic parameter. For the client API, there are login and registration methods
99
//! provided for the client (feature `client-api`):
1010
//!
11-
//! ```ignore
12-
//! # // HACK: "ignore" the doctest here because client.log_in needs client-api feature.
13-
//! // type HttpClient = ruma_client::http_client::_;
11+
//! ```no_run
12+
//! # #[cfg(feature = "client-api")]
13+
//! # async {
1414
//! # type HttpClient = ruma_client::http_client::Dummy;
15-
//! # let work = async {
1615
//! let homeserver_url = "https://example.com".to_owned();
17-
//! let client = ruma::Client::builder()
16+
//! let client = ruma_client::Client::builder()
1817
//! .homeserver_url(homeserver_url)
19-
//! .build::<ruma_client::http_client::Dummy>()
18+
//! .build::<HttpClient>()
2019
//! .await?;
2120
//!
2221
//! let session = client
@@ -61,14 +60,17 @@
6160
//! ```no_run
6261
//! # #[cfg(feature = "client-api")]
6362
//! # async {
63+
//! # type HttpClient = ruma_client::http_client::Dummy;
6464
//! # let homeserver_url = "https://example.com".to_owned();
6565
//! # let client = ruma_client::Client::builder()
6666
//! # .homeserver_url(homeserver_url)
67-
//! # .build::<ruma_client::http_client::Dummy>()
67+
//! # .build::<HttpClient>()
6868
//! # .await?;
6969
//!
70-
//! use ruma_client_api::alias::get_alias;
71-
//! use ruma_common::{api::MatrixVersion, owned_room_alias_id, room_id};
70+
//! use ruma::{
71+
//! api::{client::alias::get_alias, MatrixVersion},
72+
//! owned_room_alias_id, room_id,
73+
//! };
7274
//!
7375
//! let alias = owned_room_alias_id!("#example_room:example.com");
7476
//! let response = client.send_request(get_alias::v3::Request::new(alias)).await?;
@@ -101,7 +103,9 @@
101103

102104
use std::{any::type_name, future::Future};
103105

104-
use ruma_common::{
106+
#[doc(no_inline)]
107+
pub use ruma;
108+
use ruma::{
105109
api::{MatrixVersion, OutgoingRequest, SendAccessToken},
106110
UserId,
107111
};
@@ -167,9 +171,7 @@ where
167171

168172
let res =
169173
info_span!("deserialize_response", response_type = type_name::<R::IncomingResponse>())
170-
.in_scope(move || {
171-
ruma_common::api::IncomingResponse::try_from_http_response(http_res)
172-
})?;
174+
.in_scope(move || ruma::api::IncomingResponse::try_from_http_response(http_res))?;
173175

174176
Ok(res)
175177
}

0 commit comments

Comments
 (0)