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

Expose SerializableMap #74

Merged
merged 2 commits into from
Nov 19, 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
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
Loading