Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changelog

All notable changes to this project will be documented in this file.

## Unreleased

- Deprecated `SharedState::new` (since 0.2.0); construct via `inner.into()`
instead.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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())
})
Expand Down
2 changes: 1 addition & 1 deletion docs/rust-binary-router-library-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 4 additions & 3 deletions src/extractor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl<T: Send + Sync> SharedState<T> {
/// use wireframe::extractor::SharedState;
///
/// let data = Arc::new(5u32);
/// let state = SharedState::new(Arc::clone(&data));
/// let state: SharedState<u32> = Arc::clone(&data).into();
/// assert_eq!(*state, 5);
/// ```
#[must_use]
Expand All @@ -78,9 +78,10 @@ impl<T: Send + Sync> SharedState<T> {
/// use wireframe::extractor::SharedState;
///
/// let state = Arc::new(42);
/// let shared = SharedState::new(state.clone());
/// let shared: SharedState<u32> = state.clone().into();
/// assert_eq!(*shared, 42);
/// ```
#[deprecated(since = "0.2.0", note = "construct via `inner.into()` instead")]
pub fn new(inner: Arc<T>) -> Self {
Self(inner)
}
Expand Down Expand Up @@ -112,7 +113,7 @@ impl<T: Send + Sync> std::ops::Deref for SharedState<T> {
/// use wireframe::extractor::SharedState;
///
/// let state = Arc::new(42);
/// let shared = SharedState::new(state.clone());
/// let shared: SharedState<u32> = state.clone().into();
/// assert_eq!(*shared, 42);
/// ```
fn deref(&self) -> &Self::Target {
Expand Down