Skip to content

Commit

Permalink
Merge pull request #74 from fjarri/expose-map
Browse files Browse the repository at this point in the history
Expose `SerializableMap`
  • Loading branch information
fjarri authored Nov 19, 2024
2 parents 1394181 + aa1ffa4 commit d82678b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion manul/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion manul/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
mod serializable_map;

pub(crate) use serializable_map::SerializableMap;
pub use serializable_map::SerializableMap;
10 changes: 8 additions & 2 deletions manul/src/utils/serializable_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use alloc::{collections::BTreeMap, format};
use core::{
fmt::{self, Debug},
marker::PhantomData,
ops::Deref,
ops::{Deref, DerefMut},
};

use serde::{
Expand All @@ -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<K, V>(BTreeMap<K, V>);
pub struct SerializableMap<K, V>(BTreeMap<K, V>);

impl<K, V> From<BTreeMap<K, V>> for SerializableMap<K, V> {
fn from(source: BTreeMap<K, V>) -> Self {
Expand All @@ -34,6 +34,12 @@ impl<K, V> Deref for SerializableMap<K, V> {
}
}

impl<K, V> DerefMut for SerializableMap<K, V> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}

impl<K, V> Serialize for SerializableMap<K, V>
where
K: Serialize,
Expand Down

0 comments on commit d82678b

Please sign in to comment.