From 56459e15b80e5ea682d7c040488b1ea0a5aa6b1c Mon Sep 17 00:00:00 2001 From: Leynos Date: Sun, 15 Jun 2025 04:04:25 +0100 Subject: [PATCH 1/3] Deprecate SharedState::new --- CHANGELOG.md | 7 +++++++ README.md | 2 +- docs/rust-binary-router-library-design.md | 2 +- src/extractor.rs | 7 ++++--- 4 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..6c7a8c55 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +## Unreleased + +- Deprecated `SharedState::new`; construct via `inner.into()` instead. diff --git a/README.md b/README.md index f22072f0..3730e278 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ connections and runs the Tokio event loop: WireframeServer::new(|| { WireframeApp::new() .frame_processor(MyFrameProcessor::new()) - .app_data(SharedState::new(state.clone())) + .app_data(state.clone().into()) .route(MessageType::Login, handle_login) .wrap(MyLoggingMiddleware::default()) }) diff --git a/docs/rust-binary-router-library-design.md b/docs/rust-binary-router-library-design.md index 7b6ef325..3b72a367 100644 --- a/docs/rust-binary-router-library-design.md +++ b/docs/rust-binary-router-library-design.md @@ -624,7 +624,7 @@ WireframeApp::new() .frame_processor(MyFrameProcessor::new()) // Configure the framing logic -.app_data(SharedState::new(app_state.clone())) // Shared application state +.app_data(app_state.clone().into()) // Shared application state //.service(login_handler) // If using attribute macros and auto-discovery diff --git a/src/extractor.rs b/src/extractor.rs index eaf02cfe..7feb2960 100644 --- a/src/extractor.rs +++ b/src/extractor.rs @@ -65,7 +65,7 @@ impl SharedState { /// use wireframe::extractor::SharedState; /// /// let data = Arc::new(5u32); - /// let state = SharedState::new(Arc::clone(&data)); + /// let state: SharedState = Arc::clone(&data).into(); /// assert_eq!(*state, 5); /// ``` #[must_use] @@ -78,9 +78,10 @@ impl SharedState { /// use wireframe::extractor::SharedState; /// /// let state = Arc::new(42); - /// let shared = SharedState::new(state.clone()); + /// let shared: SharedState = state.clone().into(); /// assert_eq!(*shared, 42); /// ``` + #[deprecated(note = "construct via `inner.into()` instead")] pub fn new(inner: Arc) -> Self { Self(inner) } @@ -112,7 +113,7 @@ impl std::ops::Deref for SharedState { /// use wireframe::extractor::SharedState; /// /// let state = Arc::new(42); - /// let shared = SharedState::new(state.clone()); + /// let shared: SharedState = state.clone().into(); /// assert_eq!(*shared, 42); /// ``` fn deref(&self) -> &Self::Target { From 5e676aa172e8098609b17718719547f5af190390 Mon Sep 17 00:00:00 2001 From: Leynos Date: Sun, 15 Jun 2025 05:11:14 +0100 Subject: [PATCH 2/3] Add deprecation version --- src/extractor.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/extractor.rs b/src/extractor.rs index 7feb2960..51ffec53 100644 --- a/src/extractor.rs +++ b/src/extractor.rs @@ -81,7 +81,7 @@ impl SharedState { /// let shared: SharedState = state.clone().into(); /// assert_eq!(*shared, 42); /// ``` - #[deprecated(note = "construct via `inner.into()` instead")] + #[deprecated(since = "0.2.0", note = "construct via `inner.into()` instead")] pub fn new(inner: Arc) -> Self { Self(inner) } From c33d6cdab20c8dafcd0e25d917186ed8ed1b1a56 Mon Sep 17 00:00:00 2001 From: Leynos Date: Sun, 15 Jun 2025 05:29:58 +0100 Subject: [PATCH 3/3] Clarify SharedState deprecation --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c7a8c55..0545544d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,4 +4,5 @@ All notable changes to this project will be documented in this file. ## Unreleased -- Deprecated `SharedState::new`; construct via `inner.into()` instead. +- Deprecated `SharedState::new` (since 0.2.0); construct via `inner.into()` + instead.