Serialize CmpValuesMetadata to an empty object to save space on State serialize
This commit is contained in:
parent
fe57c5ecd6
commit
4af9af784f
@ -5,7 +5,7 @@ use alloc::{
|
|||||||
vec::Vec,
|
vec::Vec,
|
||||||
};
|
};
|
||||||
|
|
||||||
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
use serde::{de::DeserializeOwned, Deserialize, Serialize, Serializer};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
bolts::{ownedref::OwnedRefMut, tuples::Named, AsSlice},
|
bolts::{ownedref::OwnedRefMut, tuples::Named, AsSlice},
|
||||||
@ -45,7 +45,7 @@ impl CmpValues {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A state metadata holding a list of values logged from comparisons
|
/// A state metadata holding a list of values logged from comparisons
|
||||||
#[derive(Default, Serialize, Deserialize)]
|
#[derive(Default, Deserialize)]
|
||||||
pub struct CmpValuesMetadata {
|
pub struct CmpValuesMetadata {
|
||||||
/// A `list` of values.
|
/// A `list` of values.
|
||||||
pub list: Vec<CmpValues>,
|
pub list: Vec<CmpValues>,
|
||||||
@ -53,6 +53,17 @@ pub struct CmpValuesMetadata {
|
|||||||
|
|
||||||
crate::impl_serdeany!(CmpValuesMetadata);
|
crate::impl_serdeany!(CmpValuesMetadata);
|
||||||
|
|
||||||
|
impl Serialize for CmpValuesMetadata {
|
||||||
|
/// Serialzie to an empty object, we don't need to keep it in State after reset
|
||||||
|
fn serialize<S>(&self, se: S) -> Result<S::Ok, S::Error>
|
||||||
|
where
|
||||||
|
S: Serializer,
|
||||||
|
{
|
||||||
|
let empty = CmpValuesMetadata::new();
|
||||||
|
empty.serialize(se)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl AsSlice<CmpValues> for CmpValuesMetadata {
|
impl AsSlice<CmpValues> for CmpValuesMetadata {
|
||||||
/// Convert to a slice
|
/// Convert to a slice
|
||||||
#[must_use]
|
#[must_use]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user