Enums
Basic
Schema
mabo
enum Sample {
Variant1 @1,
Variant2 @2,
}
1
2
3
4
2
3
4
Languages
rs
#[repr(u32)]
enum Sample {
Variant1 = 1,
Variant2 = 2,
// N variants...
}
1
2
3
4
5
6
2
3
4
5
6
go
type Sample uint32
const (
SampleVariant1 Sample = 1
SampleVariant2 Sample = 2
// N variants...
)
1
2
3
4
5
6
7
2
3
4
5
6
7
kt
enum class Sample(val value: Int) {
Variant1(1),
Variant2(2),
// N variants...
}
1
2
3
4
5
2
3
4
5
ts
enum Sample {
Variant1 = 1,
Variant2 = 2,
// N variants...
}
1
2
3
4
5
2
3
4
5
py
@dataclass
class Sample(Enum):
VARIANT1 = 1
VARIANT2 = 2
1
2
3
4
2
3
4
Advanced
Schema
mabo
enum Sample {
Variant1(u32 @1, u16 @2) @1,
Variant2 {
field1: i64 @1,
field2: bool @2,
} @2,
}
1
2
3
4
5
6
7
2
3
4
5
6
7
Languages
rs
enum Sample {
Variant1(u32, u16),
Variant2 { field1: i64, field2: bool },
// N variants...
}
1
2
3
4
5
2
3
4
5
go
type SampleVariant interface {
sealed()
}
type Sample SampleVariant
type Sample_Variant1 struct {
F1 uint32
F2 uint16
}
func (v Sample_Variant1) sealed() {}
type Sample_Variant2 struct {
Field1 int64
Field2 bool
}
func (v Sample_Variant2) sealed() {}
// N variants...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
kt
sealed class Sample {
class Variant1(
val f1: UInt,
val f2: UShort,
) : Sample()
class Variant2(
val field1: Long,
val field2: Boolean,
) : Sample()
// N variants...
}
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
ts
enum SampleKind {
Variant1,
Variant2,
// N variants...
}
interface SampleVariant1 {
kind: SampleKind.Variant1;
f1: number;
f2: number;
}
interface SampleVariant2 {
kind: SampleKind.Variant2;
field1: number;
field2: boolean;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
py
@dataclass
class SampleVariant1:
tag: Literal["Variant1"]
f1: int
f2: int
@dataclass
class SampleVariant2:
tag: Literal["Variant2"]
field1: int
field2: bool
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12