Skip to content

Commit

Permalink
add versionize support for more data structures
Browse files Browse the repository at this point in the history
add versionize support for VecDeque/HashMap/HashSet.

Signed-off-by: Zizheng Bian <[email protected]>
  • Loading branch information
ZizhengBian committed Dec 6, 2022
1 parent f52d387 commit 8c514c6
Show file tree
Hide file tree
Showing 3 changed files with 444 additions and 40 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# [Unreleased]

- Add versionize proc macro support for HashMap, HashSet and VecDeque.

# v0.1.9

- Implement Versionize for i128 and u128
Expand Down
18 changes: 17 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//! `Versionize` trait is implemented for the following primitives:
//! u8, u16, u32, u64, usize, i8, i16, i32, i64, isize, char, f32, f64,
//! String, Vec<T>, Arrays up to 32 elements, Box<T>, Wrapping<T>, Option<T>,
//! FamStructWrapper<T>, and (T, U).
//! FamStructWrapper<T>, VecDeque<T>, HashMap<K, V>, HashSet<T> and (T, U).
//!
//! Known issues and limitations:
//! - Union serialization is not supported via the `Versionize` proc macro.
Expand Down Expand Up @@ -59,6 +59,10 @@ pub enum VersionizeError {
StringLength(usize),
/// Vector length exceeded.
VecLength(usize),
/// HashMap length exceeded.
HashMapLength(usize),
/// HashSet length exceeded.
HashSetLength(usize),
}

impl std::fmt::Display for VersionizeError {
Expand All @@ -82,6 +86,18 @@ impl std::fmt::Display for VersionizeError {
bad_len,
primitives::MAX_VEC_SIZE
),
HashMapLength(bad_len) => write!(
f,
"HashMap of length exceeded {} > {} bytes",
bad_len,
primitives::MAX_HASH_MAP_LEN
),
HashSetLength(bad_len) => write!(
f,
"HashSet of length exceeded {} > {} bytes",
bad_len,
primitives::MAX_HASH_SET_LEN
),
}
}
}
Expand Down
Loading

0 comments on commit 8c514c6

Please sign in to comment.