diff --git a/Cargo.lock b/Cargo.lock index 2ae89afc7465..4533257660ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1868,7 +1868,7 @@ checksum = "55b672471b4e9f9e95499ea597ff64941a309b2cdbffcc46f2cc5e2d971fd335" name = "common-base" version = "0.9.3" dependencies = [ - "anymap", + "anymap2", "async-trait", "bitvec", "bytes", diff --git a/src/common/base/Cargo.toml b/src/common/base/Cargo.toml index 5afbc3b88c29..5dfde47bf2ee 100644 --- a/src/common/base/Cargo.toml +++ b/src/common/base/Cargo.toml @@ -8,7 +8,7 @@ license.workspace = true workspace = true [dependencies] -anymap = "1.0.0-beta.2" +anymap2 = "0.13" async-trait.workspace = true bitvec = "1.0" bytes.workspace = true diff --git a/src/common/base/src/plugins.rs b/src/common/base/src/plugins.rs index 84d78b0c91aa..98b40cd059b2 100644 --- a/src/common/base/src/plugins.rs +++ b/src/common/base/src/plugins.rs @@ -12,20 +12,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::any::Any; use std::sync::{Arc, RwLock, RwLockReadGuard, RwLockWriteGuard}; -/// [`Plugins`] is a wrapper of [AnyMap](https://github.com/chris-morgan/anymap) and provides a thread-safe way to store and retrieve plugins. +use anymap2::SendSyncAnyMap; + +/// [`Plugins`] is a wrapper of [anymap2](https://github.com/azriel91/anymap2) and provides a thread-safe way to store and retrieve plugins. /// Make it Cloneable and we can treat it like an Arc struct. #[derive(Default, Clone)] pub struct Plugins { - inner: Arc>>, + inner: Arc>, } impl Plugins { pub fn new() -> Self { Self { - inner: Arc::new(RwLock::new(anymap::Map::new())), + inner: Arc::new(RwLock::new(SendSyncAnyMap::new())), } } @@ -61,11 +62,11 @@ impl Plugins { self.read().is_empty() } - fn read(&self) -> RwLockReadGuard> { + fn read(&self) -> RwLockReadGuard { self.inner.read().unwrap() } - fn write(&self) -> RwLockWriteGuard> { + fn write(&self) -> RwLockWriteGuard { self.inner.write().unwrap() } }