Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): remove useless dashmap dep and improve doc #328

Merged
merged 1 commit into from
Jun 4, 2024
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
5 changes: 1 addition & 4 deletions socketioxide/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ itoa.workspace = true
hyper.workspace = true
pin-project-lite.workspace = true

# Extensions
dashmap = { version = "5.4.0", optional = true }

# Tracing
tracing = { workspace = true, optional = true }

Expand All @@ -41,7 +38,7 @@ state = { version = "0.6.0", optional = true }
[features]
v4 = ["engineioxide/v3"]
tracing = ["dep:tracing", "engineioxide/tracing"]
extensions = ["dep:dashmap"]
extensions = []
state = ["dep:state"]

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion socketioxide/src/extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use std::{
/// TypeMap value
type AnyVal = Box<dyn Any + Send + Sync>;

/// The `AnyDashMap` is a `HashMap` that uses `TypeId` as keys and `Any` as values.
/// The [`AnyHashMap`] is a [`HashMap`] that uses `TypeId` as keys and `Any` as values.
type AnyHashMap = RwLock<HashMap<TypeId, AnyVal, BuildHasherDefault<IdHasher>>>;

// With TypeIds as keys, there's no need to hash them. They are already hashes
Expand Down
5 changes: 3 additions & 2 deletions socketioxide/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,9 @@
//!
//! #### Per socket state
//! You can enable the `extensions` feature and use the [`extensions`](socket::Socket::extensions) field on any socket to manage
//! the state of each socket. It is backed by a [`dashmap`] so you can safely access it from multiple threads.
//! Beware that deadlocks can easily occur if you hold a value ref and try to remove it at the same time.
//! the state of each socket. It is backed by a [`RwLock<HashMap>>`](std::sync::RwLock) so you can safely access it
//! from multiple threads. However, the value must be [`Clone`] and `'static`.
//! When calling get, or using the [`Extension`](extract::Extension) extractor, the value will always be cloned.
//! See the [`extensions`] module doc for more details.
//!
//! #### Global state
Expand Down
2 changes: 1 addition & 1 deletion socketioxide/src/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ pub struct Socket<A: Adapter = LocalAdapter> {

/// A type map of protocol extensions.
/// It can be used to share data through the lifetime of the socket.
/// Because it uses a [`DashMap`](dashmap::DashMap) internally, it is thread safe but be careful about deadlocks!
///
/// **Note**: This is note the same data than the `extensions` field on the [`http::Request::extensions()`](http::Request) struct.
/// If you want to extract extensions from the http request, you should use the [`HttpExtension`](crate::extract::HttpExtension) extractor.
#[cfg_attr(docsrs, doc(cfg(feature = "extensions")))]
#[cfg(feature = "extensions")]
pub extensions: Extensions,
Expand Down