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 e00a8b5 commit ce133f5
Show file tree
Hide file tree
Showing 4 changed files with 445 additions and 41 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.6

- Upraded vmm-sys-utils to v0.8.0
Expand Down
2 changes: 1 addition & 1 deletion coverage_config_x86_64.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"coverage_score": 96.2, "exclude_path": "test", "crate_features": ""}
{"coverage_score": 96.7, "exclude_path": "test", "crate_features": ""}
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 ce133f5

Please sign in to comment.