Restore typed data to serialized PODs (#318)

This commit is contained in:
Rob Knight 2025-06-28 07:53:31 +02:00 committed by GitHub
parent 3306f360f7
commit 6aa4acac4a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,10 +1,14 @@
use std::collections::HashMap;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use super::Error;
use crate::{
frontend::{MainPod, SignedPod},
middleware::{deserialize_pod, deserialize_signed_pod, Params, PodId, VDSet},
middleware::{
deserialize_pod, deserialize_signed_pod, Key, Params, PodId, Statement, VDSet, Value,
},
};
#[derive(Serialize, Deserialize, JsonSchema)]
@ -19,6 +23,7 @@ pub enum SignedPodType {
pub struct SerializedSignedPod {
pod_type: (usize, String),
id: PodId,
entries: HashMap<Key, Value>,
data: serde_json::Value,
}
@ -30,6 +35,7 @@ pub struct SerializedMainPod {
pod_type: (usize, String),
id: PodId,
vd_set: VDSet,
public_statements: Vec<Statement>,
data: serde_json::Value,
}
@ -40,6 +46,7 @@ impl From<SignedPod> for SerializedSignedPod {
SerializedSignedPod {
pod_type: (pod_type, pod_type_name_str.to_string()),
id: pod.id(),
entries: pod.kvs().clone(),
data,
}
}
@ -64,6 +71,7 @@ impl From<MainPod> for SerializedMainPod {
id: pod.id(),
vd_set: pod.pod.vd_set().clone(),
params: pod.params.clone(),
public_statements: pod.pod.pub_statements(),
data,
}
}