Assorted tweaks to support external playground crate (#322)

* Assorted tweaks to support external playground crate

* Fix schemas

* Fixed schema again

* Add ToHex for RawValue

* Add FromHex to RawValue
This commit is contained in:
Rob Knight 2025-07-02 18:27:54 +02:00 committed by GitHub
parent 335100d1d7
commit 24cafde231
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 111 additions and 46 deletions

View file

@ -5,7 +5,7 @@ use std::{collections::HashMap, convert::From, fmt};
use itertools::Itertools;
use serde::{Deserialize, Serialize};
use serialization::{SerializedMainPod, SerializedSignedPod};
pub use serialization::{SerializedMainPod, SerializedSignedPod};
use crate::middleware::{
self, check_st_tmpl, hash_op, hash_str, max_op, prod_op, sum_op, AnchoredKey, Key,

View file

@ -17,7 +17,7 @@ pub enum SignedPodType {
MockSigned,
}
#[derive(Serialize, Deserialize, JsonSchema)]
#[derive(Serialize, Deserialize, JsonSchema, Debug, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
#[schemars(rename = "SignedPod")]
pub struct SerializedSignedPod {
@ -27,7 +27,7 @@ pub struct SerializedSignedPod {
data: serde_json::Value,
}
#[derive(Serialize, Deserialize, JsonSchema)]
#[derive(Serialize, Deserialize, JsonSchema, Debug, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
#[schemars(rename = "MainPod")]
pub struct SerializedMainPod {
@ -154,11 +154,11 @@ mod tests {
]))
.unwrap(),
),
"{\"Dictionary\":{\"max_depth\":32,\"kvs\":{\"\":\"baz\",\"\\u0000\":\"\",\" hi\":false,\"!@£$%^&&*()\":\"\",\"foo\":{\"Int\":\"123\"},\"🥳\":\"party time!\"}}}",
"{\"max_depth\":32,\"kvs\":{\"\":\"baz\",\"\\u0000\":\"\",\" hi\":false,\"!@£$%^&&*()\":\"\",\"foo\":{\"Int\":\"123\"},\"🥳\":\"party time!\"}}",
),
(
TypedValue::Set(Set::new(params.max_depth_mt_containers, HashSet::from(["foo".into(), "bar".into()])).unwrap()),
"{\"Set\":{\"max_depth\":32,\"set\":[\"bar\",\"foo\"]}}",
"{\"max_depth\":32,\"set\":[\"bar\",\"foo\"]}",
),
];