Re-implement serialization (#201)
* Serialization tests now pass again * Tidy up and test more edge-cases * Use attributes rather than custom serializer for arrays * Add JSON Schema support * Tests for JSON Schema generation and validation * Add comments * Support custom predicates * Clippy fixes * Make deserialization/constructor functions pub(crate)
This commit is contained in:
parent
26a6b2d143
commit
bf6d8aee8b
17 changed files with 554 additions and 255 deletions
|
|
@ -5,10 +5,8 @@ use std::{collections::HashMap, convert::From, fmt};
|
|||
|
||||
use anyhow::{anyhow, Result};
|
||||
use itertools::Itertools;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
// use schemars::JsonSchema;
|
||||
|
||||
// use serde::{Deserialize, Serialize};
|
||||
use crate::middleware::{
|
||||
self, check_st_tmpl, hash_str, AnchoredKey, Key, MainPodInputs, NativeOperation,
|
||||
NativePredicate, OperationAux, OperationType, Params, PodId, PodProver, PodSigner, Predicate,
|
||||
|
|
@ -17,8 +15,10 @@ use crate::middleware::{
|
|||
|
||||
mod custom;
|
||||
mod operation;
|
||||
mod serialization;
|
||||
pub use custom::*;
|
||||
pub use operation::*;
|
||||
use serialization::*;
|
||||
|
||||
/// This type is just for presentation purposes.
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq)]
|
||||
|
|
@ -66,8 +66,8 @@ impl SignedPodBuilder {
|
|||
|
||||
/// SignedPod is a wrapper on top of backend::SignedPod, which additionally stores the
|
||||
/// string<-->hash relation of the keys.
|
||||
#[derive(Debug, Clone)]
|
||||
// #[serde(try_from = "SignedPodHelper", into = "SignedPodHelper")]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(try_from = "SignedPodHelper", into = "SignedPodHelper")]
|
||||
pub struct SignedPod {
|
||||
pub pod: Box<dyn middleware::Pod>,
|
||||
// We store a copy of the key values for quick access
|
||||
|
|
@ -591,8 +591,8 @@ impl MainPodBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
// #[serde(try_from = "MainPodHelper", into = "MainPodHelper")]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(try_from = "MainPodHelper", into = "MainPodHelper")]
|
||||
pub struct MainPod {
|
||||
pub pod: Box<dyn middleware::Pod>,
|
||||
pub public_statements: Vec<Statement>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue