use anyhow::Result; use serde::{Deserialize, Serialize}; use serde_json::Value; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Lex { pub lexicon: u32, pub id: String, pub defs: serde_json::Map, } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct LexDef { #[serde(rename = "type")] pub def_type: String, #[serde(flatten)] pub extra: serde_json::Map, } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct LexRecord { #[serde(rename = "type")] pub def_type: String, pub key: String, pub record: Value, } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Record { pub collection: String, pub value: Value, } impl Lex { pub fn from_json(s: &str) -> Result { Ok(serde_json::from_str(s)?) } }