pulumi_wasm_rust/
oneof.rs

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
use serde::{Deserialize, Serialize};
use std::fmt::Debug;

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[serde(untagged)]
pub enum OneOf2<A: Serialize + Debug, B: Serialize + Debug> {
    Left(A),
    Right(B),
}

impl<A: Serialize + Debug, B: Serialize + Debug> OneOf2<A, B> {
    pub fn left(a: A) -> Self {
        OneOf2::Left(a)
    }
    pub fn right(b: B) -> Self {
        OneOf2::Right(b)
    }
}

#[derive(Debug, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OneOf3<A: Serialize + Debug, B: Serialize + Debug, C: Serialize + Debug> {
    Left(A),
    Middle(B),
    Right(C),
}

impl<A: Serialize + Debug, B: Serialize + Debug, C: Serialize + Debug> OneOf3<A, B, C> {
    pub fn left(a: A) -> Self {
        OneOf3::Left(a)
    }
    pub fn middle(b: B) -> Self {
        OneOf3::Middle(b)
    }
    pub fn right(c: C) -> Self {
        OneOf3::Right(c)
    }
}

#[derive(Debug, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OneOf4<
    A: Serialize + Debug,
    B: Serialize + Debug,
    C: Serialize + Debug,
    D: Serialize + Debug,
> {
    Left(A),
    Middle1(B),
    Middle2(C),
    Right(D),
}

impl<A: Serialize + Debug, B: Serialize + Debug, C: Serialize + Debug, D: Serialize + Debug>
    OneOf4<A, B, C, D>
{
    pub fn left(a: A) -> Self {
        OneOf4::Left(a)
    }
    pub fn middle1(b: B) -> Self {
        OneOf4::Middle1(b)
    }
    pub fn middle2(c: C) -> Self {
        OneOf4::Middle2(c)
    }
    pub fn right(d: D) -> Self {
        OneOf4::Right(d)
    }
}