Implement serde's Deserialize for blueprints.

Here's a trick though: I got lazy (a bit) and did not write a full deserializer for Schema because this is busywork and not at all necessary at this stage. Instead, I've made the blueprint parameterized by a generic type <T>; which represents the type of the underlying blueprint's schema. When deserializing from JSON, we can default to 'Value' to get a free deserializer. Since all we're interested about is the program and the metadata (purpose and title) of a validator, it works nicely.

  Serialization however expects a Blueprint<Schema>, and most of the functions operates over a Blueprint<Schema> anyway.
This commit is contained in:
KtorZ
2023-01-31 15:26:41 +01:00
parent cab59c188a
commit 1aa12fb368
4 changed files with 39 additions and 68 deletions

View File

@@ -16,7 +16,7 @@ use std::{
sync::Arc,
};
#[derive(Debug, PartialEq, Eq, Clone, serde::Serialize)]
#[derive(Debug, PartialEq, Eq, Clone, serde::Serialize, serde::Deserialize)]
pub struct Annotated<T> {
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<String>,