1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//! Utilities for serializing and exporting type information about MAF apps.
//!
//! The features described by this trait are minimally intrusive and optional (enabled through the
//! `typed` feature). To use this feature, the types being exported (RPC parameters, RPC return,
//! and store value types) must implement [`schemars::JsonSchema`], a trait that provides type
//! introspection using JSON Schema. Most primitive types already implement this trait, and for
//! custom types, it can be implemented using the derive macro.
//!
//! [`schemars::JsonSchema`] is compatible with [`serde`], recognizing `#[serde]` attributes like
//! field renames, enum tagging, defaults, and so on. See the
//! [`schemars` documentation](https://graham.cool/schemars/examples/2-serde_attrs) for more
//! information.
//!
//! ## Example
//!
//! ```rust
//! #[derive(serde::Serialize, schemars::JsonSchema)]
//! #[serde(rename_all = "camelCase")]
//! struct Game {
//! points: i32,
//! round: u32,
//! phase: String,
//! // The `next_phase` field will be serialized as `nextPhase`
//! next_phase: Option<String>,
//! }
//!
//! impl StoreData for Game {
//! type Select<'this> = &'this Game;
//! // ^^^^^^^^^^^ Store::Select must implement `JsonSchema`
//! // ...
//! }
//!
//! fn make_move(params: Params<(u32, u32)>) -> String {
//! // ^^^^^^^^^^ ^^^^^^
//! // Parameter and return types must implement `JsonSchema`
//! // ...
//! }
//!
//! fn build() -> App {
//! App::builder()
//! // Types should be statically registered in the app builder
//! .store::<Game>()
//! .rpc("make_move", make_move)
//! // ...
//! .build()
//! }
//!
//! ```
//!
//! ## ⚠️ Work in Progress ⚠️
//!
//! Currently, only types for RPCs and stores are exported. This is used for generating types for
//! the client (e.g. in TypeScript, this allows for type-safe RPC calls and store access).
pub use ;
pub use ;
use crate::;