jacquard_api/pub_leaflet/blocks/
code.rs1use jacquard_common::CowStr;
9
10#[allow(unused_imports)]
11use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
12use jacquard_derive::{IntoStatic, lexicon};
13use jacquard_lexicon::lexicon::LexiconDoc;
14use jacquard_lexicon::schema::LexiconSchema;
15
16#[allow(unused_imports)]
17use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
18use serde::{Serialize, Deserialize};
19
20#[lexicon]
21#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
22#[serde(rename_all = "camelCase")]
23pub struct Code<'a> {
24 #[serde(skip_serializing_if = "Option::is_none")]
25 #[serde(borrow)]
26 pub language: Option<CowStr<'a>>,
27 #[serde(borrow)]
28 pub plaintext: CowStr<'a>,
29 #[serde(skip_serializing_if = "Option::is_none")]
30 #[serde(borrow)]
31 pub syntax_highlighting_theme: Option<CowStr<'a>>,
32}
33
34impl<'a> LexiconSchema for Code<'a> {
35 fn nsid() -> &'static str {
36 "pub.leaflet.blocks.code"
37 }
38 fn def_name() -> &'static str {
39 "main"
40 }
41 fn lexicon_doc() -> LexiconDoc<'static> {
42 lexicon_doc_pub_leaflet_blocks_code()
43 }
44 fn validate(&self) -> Result<(), ConstraintError> {
45 Ok(())
46 }
47}
48
49fn lexicon_doc_pub_leaflet_blocks_code() -> LexiconDoc<'static> {
50 #[allow(unused_imports)]
51 use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
52 use jacquard_lexicon::lexicon::*;
53 use alloc::collections::BTreeMap;
54 LexiconDoc {
55 lexicon: Lexicon::Lexicon1,
56 id: CowStr::new_static("pub.leaflet.blocks.code"),
57 defs: {
58 let mut map = BTreeMap::new();
59 map.insert(
60 SmolStr::new_static("main"),
61 LexUserType::Object(LexObject {
62 required: Some(vec![SmolStr::new_static("plaintext")]),
63 properties: {
64 #[allow(unused_mut)]
65 let mut map = BTreeMap::new();
66 map.insert(
67 SmolStr::new_static("language"),
68 LexObjectProperty::String(LexString { ..Default::default() }),
69 );
70 map.insert(
71 SmolStr::new_static("plaintext"),
72 LexObjectProperty::String(LexString { ..Default::default() }),
73 );
74 map.insert(
75 SmolStr::new_static("syntaxHighlightingTheme"),
76 LexObjectProperty::String(LexString { ..Default::default() }),
77 );
78 map
79 },
80 ..Default::default()
81 }),
82 );
83 map
84 },
85 ..Default::default()
86 }
87}