From e60b07336dca753a40f016d269dfefdd9f8c134b Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Fri, 11 Mar 2022 12:10:38 +0100 Subject: [PATCH] Rename Client::{new_with_config => with_config} --- crates/matrix-sdk/examples/autojoin.rs | 2 +- crates/matrix-sdk/examples/command_bot.rs | 2 +- crates/matrix-sdk/src/client.rs | 22 +++++++++++----------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/crates/matrix-sdk/examples/autojoin.rs b/crates/matrix-sdk/examples/autojoin.rs index 82046bae4..490ce29d1 100644 --- a/crates/matrix-sdk/examples/autojoin.rs +++ b/crates/matrix-sdk/examples/autojoin.rs @@ -66,7 +66,7 @@ async fn login_and_sync( } let homeserver_url = Url::parse(&homeserver_url).expect("Couldn't parse the homeserver URL"); - let client = Client::new_with_config(homeserver_url, client_config).await.unwrap(); + let client = Client::with_config(homeserver_url, client_config).await.unwrap(); client.login(username, password, None, Some("autojoin bot")).await?; diff --git a/crates/matrix-sdk/examples/command_bot.rs b/crates/matrix-sdk/examples/command_bot.rs index f5f930747..3028a1f37 100644 --- a/crates/matrix-sdk/examples/command_bot.rs +++ b/crates/matrix-sdk/examples/command_bot.rs @@ -59,7 +59,7 @@ async fn login_and_sync( let homeserver_url = Url::parse(&homeserver_url).expect("Couldn't parse the homeserver URL"); // create a new Client with the given homeserver url and config - let client = Client::new_with_config(homeserver_url, client_config).await.unwrap(); + let client = Client::with_config(homeserver_url, client_config).await.unwrap(); client.login(&username, &password, None, Some("command bot")).await?; diff --git a/crates/matrix-sdk/src/client.rs b/crates/matrix-sdk/src/client.rs index d036a47af..441e76a68 100644 --- a/crates/matrix-sdk/src/client.rs +++ b/crates/matrix-sdk/src/client.rs @@ -163,7 +163,7 @@ impl Client { /// * `homeserver_url` - The homeserver that the client should connect to. pub async fn new(homeserver_url: Url) -> Result { let config = ClientConfig::new(); - Client::new_with_config(homeserver_url, config).await + Client::with_config(homeserver_url, config).await } /// Create a new [`Client`] for the given homeserver and use the given @@ -174,7 +174,7 @@ impl Client { /// * `homeserver_url` - The homeserver that the client should connect to. /// /// * `config` - Configuration for the client. - pub async fn new_with_config(homeserver_url: Url, config: ClientConfig) -> Result { + pub async fn with_config(homeserver_url: Url, config: ClientConfig) -> Result { let homeserver = Arc::new(RwLock::new(homeserver_url)); let client = if let Some(client) = config.client { @@ -264,7 +264,7 @@ impl Client { config: ClientConfig, ) -> Result { let homeserver = Client::homeserver_from_user_id(user_id)?; - let client = Client::new_with_config(homeserver, config).await?; + let client = Client::with_config(homeserver, config).await?; let well_known = client.discover_homeserver().await?; let well_known = Url::parse(well_known.homeserver.base_url.as_ref())?; @@ -2386,7 +2386,7 @@ pub(crate) mod test { }; let homeserver = url::Url::parse(&mockito::server_url()).unwrap(); let config = ClientConfig::new().request_config(RequestConfig::new().disable_retry()); - let client = Client::new_with_config(homeserver, config).await.unwrap(); + let client = Client::with_config(homeserver, config).await.unwrap(); client.restore_login(session).await.unwrap(); client @@ -2485,7 +2485,7 @@ pub(crate) mod test { let homeserver = Url::from_str(&mockito::server_url()).unwrap(); let config = ClientConfig::new().use_discovery_response(); - let client = Client::new_with_config(homeserver, config).await.unwrap(); + let client = Client::with_config(homeserver, config).await.unwrap(); let _m_login = mock("POST", "/_matrix/client/r0/login") .with_status(200) @@ -2505,7 +2505,7 @@ pub(crate) mod test { let homeserver = Url::from_str(&mockito::server_url()).unwrap(); let config = ClientConfig::new().use_discovery_response(); - let client = Client::new_with_config(homeserver.clone(), config).await.unwrap(); + let client = Client::with_config(homeserver.clone(), config).await.unwrap(); let _m_login = mock("POST", "/_matrix/client/r0/login") .with_status(200) @@ -2634,7 +2634,7 @@ pub(crate) mod test { // test store reloads with correct room state from the state store let config = ClientConfig::new().request_config(RequestConfig::new().disable_retry()); - let joined_client = Client::new_with_config(homeserver, config).await.unwrap(); + let joined_client = Client::with_config(homeserver, config).await.unwrap(); joined_client.restore_login(session).await.unwrap(); // joined room reloaded from state store @@ -2696,7 +2696,7 @@ pub(crate) mod test { async fn login_error() { let homeserver = Url::from_str(&mockito::server_url()).unwrap(); let config = ClientConfig::default().request_config(RequestConfig::new().disable_retry()); - let client = Client::new_with_config(homeserver, config).await.unwrap(); + let client = Client::with_config(homeserver, config).await.unwrap(); let _m = mock("POST", "/_matrix/client/r0/login") .with_status(403) @@ -3613,7 +3613,7 @@ pub(crate) mod test { let homeserver = Url::from_str(&mockito::server_url()).unwrap(); let config = ClientConfig::default().request_config(RequestConfig::new().retry_limit(3)); assert!(config.request_config.retry_limit.unwrap() == 3); - let client = Client::new_with_config(homeserver, config).await.unwrap(); + let client = Client::with_config(homeserver, config).await.unwrap(); let m = mock("POST", "/_matrix/client/r0/login").with_status(501).expect(3).create(); @@ -3632,7 +3632,7 @@ pub(crate) mod test { let config = ClientConfig::default() .request_config(RequestConfig::new().retry_timeout(retry_timeout)); assert!(config.request_config.retry_timeout.unwrap() == retry_timeout); - let client = Client::new_with_config(homeserver, config).await.unwrap(); + let client = Client::with_config(homeserver, config).await.unwrap(); let m = mock("POST", "/_matrix/client/r0/login").with_status(501).expect_at_least(2).create(); @@ -3829,7 +3829,7 @@ pub(crate) mod test { .create(); let config = ClientConfig::default().request_config(RequestConfig::new().retry_limit(3)); - let client = Client::new_with_config(homeserver.clone(), config).await.unwrap(); + let client = Client::with_config(homeserver.clone(), config).await.unwrap(); client.restore_login(session.clone()).await.unwrap(); let room = client.get_joined_room(room_id);