From aafe4ba1b9912b03cf616db7403628fc2bd82eb1 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Mon, 15 Jan 2024 22:24:41 +0000 Subject: [PATCH] clippy & fmt & update changelog/ readme --- CHANGELOG.md | 1 + Cargo.toml | 2 +- README.md | 5 +++++ src/container_as_blob.rs | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b74877..a8819dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Add `container_as_blob` ([#63](https://github.com/monero-rs/monero-epee-bin-serde/pull/63)) - Allow optional values ([#59](https://github.com/monero-rs/monero-epee-bin-serde/pull/59)) - Updated Rust version to 2021 and bumped MSRV to 1.63 ([#52](https://github.com/monero-rs/monero-epee-bin-serde/pull/52)). diff --git a/Cargo.toml b/Cargo.toml index 08cf6e1..559780f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,6 +25,6 @@ serde_bytes = { version = "0.11", optional = true } hex = "0.4" hex-literal = "0.4" monero = "0.19" +rand = "0.8" serde = { version = "1", features = ["derive"] } serde_with = "3" -rand = "0.8" diff --git a/README.md b/README.md index f85eef8..f2e0dd2 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,11 @@ This crate implements the binary encoding defined in the `epee` helper library o [0]: https://github.com/monero-project/monero/blob/0a1ddc2eff854f3e932203a95b65a9f1efd60eef/contrib/epee/include/storages/portable_storage_from_bin.h [1]: https://github.com/monero-project/monero/blob/0a1ddc2eff854f3e932203a95b65a9f1efd60eef/contrib/epee/include/storages/portable_storage_to_bin.h +## Regressions + +Due to limitations of `serde` and weirdness in `epee` you need to wrap containers like `Vec` in `#[serde(default = "Vec::new")]` and +optionally you can add `#[serde(skip_serializing_if = "Vec::is_empty")]` as `epee` does not serialize the first field of an array. + ## License Licensed under either of diff --git a/src/container_as_blob.rs b/src/container_as_blob.rs index 04631e0..5545051 100644 --- a/src/container_as_blob.rs +++ b/src/container_as_blob.rs @@ -143,7 +143,7 @@ mod tests { let bytes = to_bytes(&t).unwrap(); - let tt = from_bytes(&bytes).unwrap(); + let tt = from_bytes(bytes).unwrap(); assert_eq!(t, tt); }