diff --git a/CHANGELOG.md b/CHANGELOG.md index d9e2a11..635f84c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `EntryPoint::ENTRY_ROUND` constant. ([#60]) - `Round::echo_round_participation()`. ([#67]) - `SessionReport::result()`. ([#71]) +- `utils::SerializableMap`. ([#74]) [#32]: https://github.com/entropyxyz/manul/pull/32 @@ -64,6 +65,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#68]: https://github.com/entropyxyz/manul/pull/68 [#71]: https://github.com/entropyxyz/manul/pull/71 [#72]: https://github.com/entropyxyz/manul/pull/72 +[#74]: https://github.com/entropyxyz/manul/pull/74 ## [0.0.1] - 2024-10-12 diff --git a/manul/src/lib.rs b/manul/src/lib.rs index df54003..8ad85bc 100644 --- a/manul/src/lib.rs +++ b/manul/src/lib.rs @@ -18,7 +18,7 @@ extern crate alloc; pub mod combinators; pub mod protocol; pub mod session; -pub(crate) mod utils; +pub mod utils; #[cfg(any(test, feature = "dev"))] pub mod dev; diff --git a/manul/src/utils.rs b/manul/src/utils.rs index 947a4bc..856394a 100644 --- a/manul/src/utils.rs +++ b/manul/src/utils.rs @@ -2,4 +2,4 @@ mod serializable_map; -pub(crate) use serializable_map::SerializableMap; +pub use serializable_map::SerializableMap; diff --git a/manul/src/utils/serializable_map.rs b/manul/src/utils/serializable_map.rs index eb46988..af9e019 100644 --- a/manul/src/utils/serializable_map.rs +++ b/manul/src/utils/serializable_map.rs @@ -2,7 +2,7 @@ use alloc::{collections::BTreeMap, format}; use core::{ fmt::{self, Debug}, marker::PhantomData, - ops::Deref, + ops::{Deref, DerefMut}, }; use serde::{ @@ -18,7 +18,7 @@ use serde::{ /// This implementation serializes maps as sequences of key/value pairs, /// and checks for duplicate keys on deserialization. #[derive(Debug, Clone, PartialEq, Eq)] -pub(crate) struct SerializableMap(BTreeMap); +pub struct SerializableMap(BTreeMap); impl From> for SerializableMap { fn from(source: BTreeMap) -> Self { @@ -34,6 +34,12 @@ impl Deref for SerializableMap { } } +impl DerefMut for SerializableMap { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } +} + impl Serialize for SerializableMap where K: Serialize,