From 5b9ede19046773324a25fbc4d123699230531596 Mon Sep 17 00:00:00 2001 From: MirrorMystic Date: Mon, 2 Oct 2023 18:53:25 +0300 Subject: [PATCH] Adding the serialize + deserialize traits to structs used by ExecutionResult --- core/Cargo.toml | 1 + core/src/nan_preserving_float.rs | 4 +++- core/src/value.rs | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/core/Cargo.toml b/core/Cargo.toml index 5d23498c6f..739c6fb79f 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -18,6 +18,7 @@ num-rational = { version = "0.4", default-features = false, features = ["num-big num-traits = { version = "0.2.8", default-features = false } region = { version = "3.0", optional = true } downcast-rs = { version = "1.2", default-features = false } +serde = { version = "1.0.188", features = ["derive"] } [dev-dependencies] rand = "0.8.2" diff --git a/core/src/nan_preserving_float.rs b/core/src/nan_preserving_float.rs index 58c6585bbb..ed624e0272 100644 --- a/core/src/nan_preserving_float.rs +++ b/core/src/nan_preserving_float.rs @@ -5,6 +5,8 @@ use core::{ ops::{Add, Div, Mul, Neg, Rem, Sub}, }; use num_traits::float::FloatCore; +use serde::Deserialize; +use serde::Serialize; macro_rules! impl_binop { ($for:ident, $is:ident, $op:ident, $func_name:ident) => { @@ -32,7 +34,7 @@ macro_rules! float { ); }; ($for:ident, $rep:ident, $is:ident, $sign_bit:expr) => { - #[derive(Copy, Clone)] + #[derive(Copy, Clone, Deserialize, Serialize)] pub struct $for($rep); impl_binop!($for, $is, Add, add); diff --git a/core/src/value.rs b/core/src/value.rs index 65f27734ce..d218a7e9a9 100644 --- a/core/src/value.rs +++ b/core/src/value.rs @@ -4,6 +4,7 @@ use crate::{ }; use core::{f32, fmt, fmt::Display, i32, i64, u32, u64}; use parity_wasm::elements as pwasm; +use serde::{Deserialize, Serialize}; /// Type of a value. /// @@ -64,7 +65,7 @@ impl ValueType { /// /// There is no distinction between signed and unsigned integer types. Instead, integers are /// interpreted by respective operations as either unsigned or signed in two’s complement representation. -#[derive(Copy, Clone, Debug, PartialEq)] +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] pub enum Value { /// Value of 32-bit signed or unsigned integer. I32(i32),