directive: start of deserialization
This commit is contained in:
parent
9b880a2b8f
commit
6b1fb10717
@ -49,6 +49,58 @@ pub enum Type {
|
||||
Enum(Vec<String>),
|
||||
}
|
||||
|
||||
// Serialized representation of directives.
|
||||
mod serial {
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "snake_case", deny_unknown_fields)]
|
||||
struct Document {
|
||||
types: Vec<Type>,
|
||||
directives: Vec<Directive>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(tag = "kind", rename_all = "snake_case", deny_unknown_fields)]
|
||||
enum TypeKind {
|
||||
Text,
|
||||
Speech,
|
||||
Character,
|
||||
Duration,
|
||||
Asset {
|
||||
tags: Vec<String>,
|
||||
},
|
||||
Enum {
|
||||
#[serde(rename = "enum")]
|
||||
enm: Vec<String>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "snake_case", deny_unknown_fields)]
|
||||
struct Type {
|
||||
name: String,
|
||||
doc: String,
|
||||
kind: TypeKind,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "snake_case", deny_unknown_fields)]
|
||||
struct Directive {
|
||||
name: String,
|
||||
doc: String,
|
||||
prefix: String,
|
||||
prefix_param: Option<String>,
|
||||
infix: Option<String>,
|
||||
infix_param: Option<String>,
|
||||
suffix: Option<String>,
|
||||
suffix_param: Option<String>,
|
||||
list_param: Option<String>,
|
||||
}
|
||||
}
|
||||
|
||||
static DIRECTIVE_PREDECLARED: &str = include_str!("directive-predeclared.json");
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
Loading…
Reference in New Issue
Block a user