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
//! # Additional Documentation
//!
//! ## Enum Serialization Convention
//!
//! Serialization of enums exposed on the conductor API in most cases follow the following
//! convention:
//!
//! 1. Enums with **only unit-like variants** have their variant names converted to `snake_case`
//! using the `#[serde(rename_all = "snake_case")]` attribute.
//!
//! For example:
//!
//! ```ignore
//! #[serde(rename_all = "snake_case")]
//! pub enum AppStatusFilter {
//! Enabled,
//! Disabled,
//! }
//! ```
//!
//! would lead to the following associated TypeScript type
//!
//! ```ignore
//! type AppStatusFilter = "enabled" | "disabled";
//! ```
//!
//! 2. Enums that **include tuple-like and/or struct-like variants** are serialized using
//! the `#[serde(tag = "type", content = "value", rename_all = "snake_case")]` attributes.
//!
//! For example:
//!
//! ```ignore
//! #[serde(tag = "type", content = "value", rename_all = "snake_case")]
//! pub enum Signal {
//! App {
//! cell_id: CellId,
//! zome_name: ZomeName,
//! signal: AppSignal,
//! },
//! System(SystemSignal),
//! }
//! ```
//!
//! would lead to the following associated TypeScript type
//!
//! ```ignore
//! type Signal =
//! | {
//! type: "app",
//! value: {
//! cell_id: CellId,
//! zome_name: ZomeName,
//! signal: AppSignal
//! }
//! }
//! | {
//! type: "system_signal"
//! value: SystemSignal
//! };
//! ```