From 49176e0207c23a85ba04cce6d7f16da0ae1b7ee4 Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Thu, 25 Apr 2024 13:21:59 -0700 Subject: [PATCH] Rename 'Rocket::configure()' to 'reconfigure'. --- core/lib/src/local/asynchronous/response.rs | 2 +- core/lib/src/local/blocking/response.rs | 2 +- core/lib/src/local/client.rs | 2 +- core/lib/src/rocket.rs | 6 ++--- core/lib/src/sentinel.rs | 4 ++-- core/lib/tests/sentinel.rs | 26 ++++++++++----------- core/lib/tests/shutdown-fairings.rs | 4 ++-- docs/guide/09-testing.md | 4 ++-- examples/tls/src/tests.rs | 2 +- testbench/src/main.rs | 22 ++++++++--------- 10 files changed, 37 insertions(+), 37 deletions(-) diff --git a/core/lib/src/local/asynchronous/response.rs b/core/lib/src/local/asynchronous/response.rs index 788ed1b8e8..06ae18e3b7 100644 --- a/core/lib/src/local/asynchronous/response.rs +++ b/core/lib/src/local/asynchronous/response.rs @@ -30,7 +30,7 @@ use crate::{Request, Response}; /// #[launch] /// fn rocket() -> _ { /// rocket::build().mount("/", routes![hello_world]) -/// # .configure(rocket::Config::debug_default()) +/// # .reconfigure(rocket::Config::debug_default()) /// } /// /// # async fn read_body_manually() -> io::Result<()> { diff --git a/core/lib/src/local/blocking/response.rs b/core/lib/src/local/blocking/response.rs index 6f1e3b82a9..207f7174f8 100644 --- a/core/lib/src/local/blocking/response.rs +++ b/core/lib/src/local/blocking/response.rs @@ -27,7 +27,7 @@ use super::Client; /// #[launch] /// fn rocket() -> _ { /// rocket::build().mount("/", routes![hello_world]) -/// # .configure(rocket::Config::debug_default()) +/// # .reconfigure(rocket::Config::debug_default()) /// } /// /// # fn read_body_manually() -> io::Result<()> { diff --git a/core/lib/src/local/client.rs b/core/lib/src/local/client.rs index 9b09ae74ff..8abc4a4864 100644 --- a/core/lib/src/local/client.rs +++ b/core/lib/src/local/client.rs @@ -141,7 +141,7 @@ macro_rules! pub_client_impl { .merge((config::Config::LOG_LEVEL, config::LogLevel::Debug)) .select(config::Config::DEBUG_PROFILE); - Self::tracked(rocket.configure(figment)) $(.$suffix)? + Self::tracked(rocket.reconfigure(figment)) $(.$suffix)? } /// Returns a reference to the `Rocket` this client is creating requests diff --git a/core/lib/src/rocket.rs b/core/lib/src/rocket.rs index 10a541f1a7..ef1f2efd40 100644 --- a/core/lib/src/rocket.rs +++ b/core/lib/src/rocket.rs @@ -229,7 +229,7 @@ impl Rocket { /// .merge((Config::IDENT, "Example")); /// /// let rocket = rocket::custom(&config) - /// .configure(figment) + /// .reconfigure(figment) /// .ignite().await?; /// /// assert_eq!(rocket.config().ident.as_str(), Some("Example")); @@ -238,7 +238,7 @@ impl Rocket { /// # }); /// ``` #[must_use] - pub fn configure(mut self, provider: T) -> Self { + pub fn reconfigure(mut self, provider: T) -> Self { self.figment = Figment::from(provider); self } @@ -522,7 +522,7 @@ impl Rocket { /// #[rocket::main] /// async fn main() -> Result<(), rocket::Error> { /// let rocket = rocket::build() - /// # .configure(rocket::Config::debug_default()) + /// # .reconfigure(rocket::Config::debug_default()) /// .attach(AdHoc::on_ignite("Manage State", |rocket| async move { /// rocket.manage(String::from("managed string")) /// })); diff --git a/core/lib/src/sentinel.rs b/core/lib/src/sentinel.rs index 02d1754601..37a149c48a 100644 --- a/core/lib/src/sentinel.rs +++ b/core/lib/src/sentinel.rs @@ -41,7 +41,7 @@ use crate::{Rocket, Ignite}; /// /// # use rocket::{Config, error::ErrorKind}; /// # rocket::async_test(async { -/// # let result = rocket().configure(Config::debug_default()).ignite().await; +/// # let result = rocket().reconfigure(Config::debug_default()).ignite().await; /// # assert!(matches!(result.unwrap_err().kind(), ErrorKind::SentinelAborts(..))); /// # }) /// ``` @@ -76,7 +76,7 @@ use crate::{Rocket, Ignite}; /// /// # use rocket::{Config, error::ErrorKind}; /// # rocket::async_test(async { -/// # rocket().configure(Config::debug_default()).ignite().await.unwrap(); +/// # rocket().reconfigure(Config::debug_default()).ignite().await.unwrap(); /// # }) /// ``` /// diff --git a/core/lib/tests/sentinel.rs b/core/lib/tests/sentinel.rs index 89f7cb5467..b9181fa73a 100644 --- a/core/lib/tests/sentinel.rs +++ b/core/lib/tests/sentinel.rs @@ -9,7 +9,7 @@ fn one_state<'r>(_three: &'r State, s: &'r str) -> &'r str { s } #[async_test] async fn state_sentinel_works() { let err = rocket::build() - .configure(Config::debug_default()) + .reconfigure(Config::debug_default()) .mount("/", routes![two_states]) .ignite().await .unwrap_err(); @@ -17,7 +17,7 @@ async fn state_sentinel_works() { assert!(matches!(err.kind(), SentinelAborts(vec) if vec.len() == 2)); let err = rocket::build() - .configure(Config::debug_default()) + .reconfigure(Config::debug_default()) .mount("/", routes![two_states]) .manage(String::new()) .ignite().await @@ -26,7 +26,7 @@ async fn state_sentinel_works() { assert!(matches!(err.kind(), SentinelAborts(vec) if vec.len() == 1)); let err = rocket::build() - .configure(Config::debug_default()) + .reconfigure(Config::debug_default()) .mount("/", routes![two_states]) .manage(1 as u32) .ignite().await @@ -35,7 +35,7 @@ async fn state_sentinel_works() { assert!(matches!(err.kind(), SentinelAborts(vec) if vec.len() == 1)); let result = rocket::build() - .configure(Config::debug_default()) + .reconfigure(Config::debug_default()) .mount("/", routes![two_states]) .manage(String::new()) .manage(1 as u32) @@ -44,7 +44,7 @@ async fn state_sentinel_works() { assert!(result.is_ok()); let err = rocket::build() - .configure(Config::debug_default()) + .reconfigure(Config::debug_default()) .mount("/", routes![one_state]) .ignite().await .unwrap_err(); @@ -52,7 +52,7 @@ async fn state_sentinel_works() { assert!(matches!(err.kind(), SentinelAborts(vec) if vec.len() == 1)); let result = rocket::build() - .configure(Config::debug_default()) + .reconfigure(Config::debug_default()) .mount("/", routes![one_state]) .manage(1 as u8) .ignite().await; @@ -60,7 +60,7 @@ async fn state_sentinel_works() { assert!(result.is_ok()); let err = rocket::build() - .configure(Config::debug_default()) + .reconfigure(Config::debug_default()) .mount("/", routes![one_state, two_states]) .ignite().await .unwrap_err(); @@ -68,7 +68,7 @@ async fn state_sentinel_works() { assert!(matches!(err.kind(), SentinelAborts(vec) if vec.len() == 3)); let err = rocket::build() - .configure(Config::debug_default()) + .reconfigure(Config::debug_default()) .mount("/", routes![one_state, two_states]) .manage(1 as u32) .ignite().await @@ -77,7 +77,7 @@ async fn state_sentinel_works() { assert!(matches!(err.kind(), SentinelAborts(vec) if vec.len() == 2)); let err = rocket::build() - .configure(Config::debug_default()) + .reconfigure(Config::debug_default()) .mount("/", routes![one_state, two_states]) .manage(1 as u8) .ignite().await @@ -86,7 +86,7 @@ async fn state_sentinel_works() { assert!(matches!(err.kind(), SentinelAborts(vec) if vec.len() == 2)); let err = rocket::build() - .configure(Config::debug_default()) + .reconfigure(Config::debug_default()) .mount("/", routes![one_state, two_states]) .manage(1 as u32) .manage(1 as u8) @@ -96,7 +96,7 @@ async fn state_sentinel_works() { assert!(matches!(err.kind(), SentinelAborts(vec) if vec.len() == 1)); let result = rocket::build() - .configure(Config::debug_default()) + .reconfigure(Config::debug_default()) .mount("/", routes![one_state, two_states]) .manage(1 as u32) .manage(1 as u8) @@ -128,7 +128,7 @@ fn with_data(_data: Data) {} #[async_test] async fn data_sentinel_works() { let err = rocket::build() - .configure(Config::debug_default()) + .reconfigure(Config::debug_default()) .mount("/", routes![with_data]) .ignite().await .unwrap_err(); @@ -136,7 +136,7 @@ async fn data_sentinel_works() { assert!(matches!(err.kind(), SentinelAborts(vec) if vec.len() == 1)); let result = rocket::build() - .configure(Config::debug_default()) + .reconfigure(Config::debug_default()) .mount("/", routes![with_data]) .manage(Data) .ignite().await; diff --git a/core/lib/tests/shutdown-fairings.rs b/core/lib/tests/shutdown-fairings.rs index edf0e2302e..6f8dc031c3 100644 --- a/core/lib/tests/shutdown-fairings.rs +++ b/core/lib/tests/shutdown-fairings.rs @@ -101,7 +101,7 @@ async fn async_slow_shutdown_doesnt_elongate_grace() { let rocket = rocket::build() .manage(Flags::default()) - .configure(config) + .reconfigure(config) .attach(AdHoc::on_shutdown("Slow Shutdown", |rocket| Box::pin(async move { tokio::time::sleep(std::time::Duration::from_secs(4)).await; let flags = rocket.state::().unwrap(); @@ -141,7 +141,7 @@ fn background_tasks_dont_prevent_terminate() { config.shutdown.grace = 1; config.shutdown.mercy = 1; - let rocket = rocket::build().configure(config).mount("/", routes![index]); + let rocket = rocket::build().reconfigure(config).mount("/", routes![index]); let client = Client::debug(rocket).unwrap(); let response = client.get("/").dispatch(); diff --git a/docs/guide/09-testing.md b/docs/guide/09-testing.md index 55395cf67c..ba7157fbe8 100644 --- a/docs/guide/09-testing.md +++ b/docs/guide/09-testing.md @@ -180,7 +180,7 @@ testing: we _want_ our tests to panic when something goes wrong. ```rust # #[rocket::launch] # fn rocket() -> _ { -# rocket::build().configure(rocket::Config::debug_default()) +# rocket::build().reconfigure(rocket::Config::debug_default()) # } # use rocket::local::blocking::Client; @@ -194,7 +194,7 @@ application's response: # use rocket::uri; # #[rocket::launch] # fn rocket() -> _ { -# rocket::build().configure(rocket::Config::debug_default()) +# rocket::build().reconfigure(rocket::Config::debug_default()) # } # #[rocket::get("/")] diff --git a/examples/tls/src/tests.rs b/examples/tls/src/tests.rs index 7cf93d5e33..eaede373e4 100644 --- a/examples/tls/src/tests.rs +++ b/examples/tls/src/tests.rs @@ -75,7 +75,7 @@ fn validate_profiles(profiles: &[&str]) { }; let figment = Config::figment().merge(config).select(profile); - let client = Client::tracked_secure(super::rocket().configure(figment)).unwrap(); + let client = Client::tracked_secure(super::rocket().reconfigure(figment)).unwrap(); let response = client.get("/").dispatch(); assert_eq!(response.into_string().unwrap(), "Hello, world!"); diff --git a/testbench/src/main.rs b/testbench/src/main.rs index da6fc3eb59..002fbb061e 100644 --- a/testbench/src/main.rs +++ b/testbench/src/main.rs @@ -34,28 +34,28 @@ static TLS_CONFIG: &str = r#" trait RocketExt { fn default() -> Self; fn tls_default() -> Self; - fn configure_with_toml(self, toml: &str) -> Self; + fn reconfigure_with_toml(self, toml: &str) -> Self; } impl RocketExt for Rocket { fn default() -> Self { - rocket::build().configure_with_toml(DEFAULT_CONFIG) + rocket::build().reconfigure_with_toml(DEFAULT_CONFIG) } fn tls_default() -> Self { rocket::build() - .configure_with_toml(DEFAULT_CONFIG) - .configure_with_toml(TLS_CONFIG) + .reconfigure_with_toml(DEFAULT_CONFIG) + .reconfigure_with_toml(TLS_CONFIG) } - fn configure_with_toml(self, toml: &str) -> Self { + fn reconfigure_with_toml(self, toml: &str) -> Self { use rocket::figment::{Figment, providers::{Format, Toml}}; let toml = toml.replace("{ROCKET}", rocket::fs::relative!("../")); let config = Figment::from(self.figment()) .merge(Toml::string(&toml).nested()); - self.configure(config) + self.reconfigure(config) } } @@ -139,7 +139,7 @@ fn tls_info() -> Result<()> { let server = Server::spawn((), |(token, _)| { let rocket = rocket::build() - .configure_with_toml(TLS_CONFIG) + .reconfigure_with_toml(TLS_CONFIG) .mount("/", routes![hello_world]); token.with_launch(rocket, |rocket| { @@ -229,7 +229,7 @@ fn test_mtls(mandatory: bool) -> Result<()> { } Rocket::tls_default() - .configure_with_toml(&mtls_config) + .reconfigure_with_toml(&mtls_config) .mount("/", routes![hello, hi]) })?; @@ -318,7 +318,7 @@ fn sni_resolver() -> Result<()> { #[get("/")] fn index() { } Rocket::default() - .configure_with_toml(SNI_TLS_CONFIG) + .reconfigure_with_toml(SNI_TLS_CONFIG) .mount("/", routes![index]) .attach(SniResolver::fairing()) }?; @@ -348,7 +348,7 @@ fn sni_resolver() -> Result<()> { fn tcp_unix_listener_fail() -> Result<()> { let server = spawn! { - Rocket::default().configure_with_toml("[default]\naddress = 123") + Rocket::default().reconfigure_with_toml("[default]\naddress = 123") }; if let Err(Error::Liftoff(stdout, _)) = server { @@ -359,7 +359,7 @@ fn tcp_unix_listener_fail() -> Result<()> { } let server = Server::spawn((), |(token, _)| { - let rocket = Rocket::default().configure_with_toml("[default]\naddress = \"unix:foo\""); + let rocket = Rocket::default().reconfigure_with_toml("[default]\naddress = \"unix:foo\""); token.launch_with::(rocket) });