Skip to content

Commit 10fee51

Browse files
committed
Upgrade Ruma
1 parent 90ff257 commit 10fee51

File tree

6 files changed

+28
-23
lines changed

6 files changed

+28
-23
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# [unreleased]
22

3+
Breaking changes:
4+
5+
- Upgrade ruma to 0.13.0.
6+
- `ClientBuilder::supported_matrix_versions()` now takes a `SupportedVersions`.
7+
38
# 0.15.0
49

510
Upgrade `ruma-client-api` to 0.20.0.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +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 = { version = "0.12.1", features = ["api"] }
45+
ruma = { version = "0.13.0", features = ["api"] }
4646
serde_html_form = "0.2.0"
4747
tracing = { version = "0.1.30", default-features = false, features = ["std"] }
4848

4949
[dev-dependencies]
50-
ruma = { version = "0.12.1", features = ["client-api-c"] }
50+
ruma = { version = "0.13.0", features = ["client-api-c"] }
5151
tokio-stream = "0.1.8"
5252

5353
[lints.rust]

src/client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use ruma::{
1414
sync::sync_events,
1515
uiaa::UserIdentifier,
1616
},
17-
MatrixVersion, OutgoingRequest, SendAccessToken,
17+
OutgoingRequest, SendAccessToken, SupportedVersions,
1818
},
1919
presence::PresenceState,
2020
DeviceId, UserId,
@@ -45,7 +45,7 @@ struct ClientData<C> {
4545
access_token: Mutex<Option<String>>,
4646

4747
/// The (known) Matrix versions the homeserver supports.
48-
supported_matrix_versions: Vec<MatrixVersion>,
48+
supported_matrix_versions: SupportedVersions,
4949
}
5050

5151
impl Client<()> {

src/client/builder.rs

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

3-
use ruma::api::{client::discovery::get_supported_versions, MatrixVersion, SendAccessToken};
3+
use ruma::api::{
4+
client::discovery::get_supported_versions, MatrixVersion, SendAccessToken, SupportedVersions,
5+
};
46

57
use super::{Client, ClientData};
68
use crate::{DefaultConstructibleHttpClient, Error, HttpClient, HttpClientExt};
@@ -11,7 +13,7 @@ use crate::{DefaultConstructibleHttpClient, Error, HttpClient, HttpClientExt};
1113
pub struct ClientBuilder {
1214
homeserver_url: Option<String>,
1315
access_token: Option<String>,
14-
supported_matrix_versions: Option<Vec<MatrixVersion>>,
16+
supported_matrix_versions: Option<SupportedVersions>,
1517
}
1618

1719
impl ClientBuilder {
@@ -37,7 +39,7 @@ impl ClientBuilder {
3739
/// This method generally *shouldn't* be called. The [`build()`][Self::build] or
3840
/// [`http_client()`][Self::http_client] method will take care of doing a
3941
/// [`get_supported_versions`] request to find out about the supported versions.
40-
pub fn supported_matrix_versions(self, versions: Vec<MatrixVersion>) -> Self {
42+
pub fn supported_matrix_versions(self, versions: SupportedVersions) -> Self {
4143
Self { supported_matrix_versions: Some(versions), ..self }
4244
}
4345

@@ -76,12 +78,14 @@ impl ClientBuilder {
7678
.send_matrix_request(
7779
&homeserver_url,
7880
SendAccessToken::None,
79-
&[MatrixVersion::V1_0],
81+
&SupportedVersions {
82+
versions: [MatrixVersion::V1_0].into(),
83+
features: Default::default(),
84+
},
8085
get_supported_versions::Request::new(),
8186
)
8287
.await?
83-
.known_versions()
84-
.collect(),
88+
.as_supported_versions(),
8589
};
8690

8791
Ok(Client(Arc::new(ClientData {

src/http_client.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::{future::Future, pin::Pin};
55

66
use bytes::BufMut;
77
use ruma::{
8-
api::{MatrixVersion, OutgoingRequest, SendAccessToken},
8+
api::{OutgoingRequest, SendAccessToken, SupportedVersions},
99
UserId,
1010
};
1111

@@ -60,7 +60,7 @@ pub trait HttpClientExt: HttpClient {
6060
&'a self,
6161
homeserver_url: &str,
6262
access_token: SendAccessToken<'_>,
63-
for_versions: &[MatrixVersion],
63+
for_versions: &SupportedVersions,
6464
request: R,
6565
) -> Pin<Box<dyn Future<Output = ResponseResult<Self, R>> + 'a + Send>> {
6666
self.send_customized_matrix_request(
@@ -79,7 +79,7 @@ pub trait HttpClientExt: HttpClient {
7979
&'a self,
8080
homeserver_url: &str,
8181
access_token: SendAccessToken<'_>,
82-
for_versions: &[MatrixVersion],
82+
for_versions: &SupportedVersions,
8383
request: R,
8484
customize: F,
8585
) -> Pin<Box<dyn Future<Output = ResponseResult<Self, R>> + 'a + Send>>
@@ -106,7 +106,7 @@ pub trait HttpClientExt: HttpClient {
106106
&'a self,
107107
homeserver_url: &str,
108108
access_token: SendAccessToken<'_>,
109-
for_versions: &[MatrixVersion],
109+
for_versions: &SupportedVersions,
110110
user_id: &'a UserId,
111111
request: R,
112112
) -> Pin<Box<dyn Future<Output = ResponseResult<Self, R>> + 'a>> {

src/lib.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,10 @@
1313
//! # async {
1414
//! # type HttpClient = ruma_client::http_client::Dummy;
1515
//! let homeserver_url = "https://example.com".to_owned();
16-
//! let client = ruma_client::Client::builder()
17-
//! .homeserver_url(homeserver_url)
18-
//! .build::<HttpClient>()
19-
//! .await?;
16+
//! let client =
17+
//! ruma_client::Client::builder().homeserver_url(homeserver_url).build::<HttpClient>().await?;
2018
//!
21-
//! let session = client
22-
//! .log_in("@alice:example.com", "secret", None, None)
23-
//! .await?;
19+
//! let session = client.log_in("@alice:example.com", "secret", None, None).await?;
2420
//!
2521
//! // You're now logged in! Write the session to a file if you want to restore it later.
2622
//! // Then start using the API!
@@ -106,7 +102,7 @@ use std::{any::type_name, future::Future};
106102
#[doc(no_inline)]
107103
pub use ruma;
108104
use ruma::{
109-
api::{MatrixVersion, OutgoingRequest, SendAccessToken},
105+
api::{OutgoingRequest, SendAccessToken, SupportedVersions},
110106
UserId,
111107
};
112108
use tracing::{info_span, Instrument};
@@ -135,7 +131,7 @@ fn send_customized_request<'a, C, R, F>(
135131
http_client: &'a C,
136132
homeserver_url: &str,
137133
send_access_token: SendAccessToken<'_>,
138-
for_versions: &[MatrixVersion],
134+
for_versions: &SupportedVersions,
139135
request: R,
140136
customize: F,
141137
) -> impl Future<Output = ResponseResult<C, R>> + Send + 'a

0 commit comments

Comments
 (0)