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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
use conjure_object::serde::{ser, de};
use conjure_object::serde::ser::SerializeStruct as SerializeStruct_;
use std::fmt;
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct GenericDiagnostic {
    diagnostic_type: String,
    value: conjure_object::Any,
}
impl GenericDiagnostic {
    /// Constructs a new instance of the type.
    #[inline]
    pub fn new<T, U>(diagnostic_type: T, value: U) -> GenericDiagnostic
    where
        T: Into<String>,
        U: conjure_object::serde::Serialize,
    {
        GenericDiagnostic {
            diagnostic_type: diagnostic_type.into(),
            value: conjure_object::Any::new(value).expect("value failed to serialize"),
        }
    }
    /// Returns a new builder.
    #[inline]
    pub fn builder() -> BuilderStage0 {
        Default::default()
    }
    ///An identifier for the type of diagnostic represented.
    #[inline]
    pub fn diagnostic_type(&self) -> &str {
        &*self.diagnostic_type
    }
    ///Observations, measurements and context associated with the diagnostic.
    #[inline]
    pub fn value(&self) -> &conjure_object::Any {
        &self.value
    }
}
impl Default for BuilderStage0 {
    #[inline]
    fn default() -> Self {
        BuilderStage0 {}
    }
}
impl From<GenericDiagnostic> for BuilderStage2 {
    #[inline]
    fn from(value: GenericDiagnostic) -> Self {
        BuilderStage2 {
            diagnostic_type: value.diagnostic_type,
            value: value.value,
        }
    }
}
///The stage 0 builder for the [`GenericDiagnostic`] type
#[derive(Debug, Clone)]
pub struct BuilderStage0 {}
impl BuilderStage0 {
    ///An identifier for the type of diagnostic represented.
    #[inline]
    pub fn diagnostic_type<T>(self, diagnostic_type: T) -> BuilderStage1
    where
        T: Into<String>,
    {
        BuilderStage1 {
            diagnostic_type: diagnostic_type.into(),
        }
    }
}
///The stage 1 builder for the [`GenericDiagnostic`] type
#[derive(Debug, Clone)]
pub struct BuilderStage1 {
    diagnostic_type: String,
}
impl BuilderStage1 {
    ///Observations, measurements and context associated with the diagnostic.
    #[inline]
    pub fn value<T>(self, value: T) -> BuilderStage2
    where
        T: conjure_object::serde::Serialize,
    {
        BuilderStage2 {
            diagnostic_type: self.diagnostic_type,
            value: conjure_object::Any::new(value).expect("value failed to serialize"),
        }
    }
}
///The stage 2 builder for the [`GenericDiagnostic`] type
#[derive(Debug, Clone)]
pub struct BuilderStage2 {
    diagnostic_type: String,
    value: conjure_object::Any,
}
impl BuilderStage2 {
    ///An identifier for the type of diagnostic represented.
    #[inline]
    pub fn diagnostic_type<T>(mut self, diagnostic_type: T) -> Self
    where
        T: Into<String>,
    {
        self.diagnostic_type = diagnostic_type.into();
        self
    }
    ///Observations, measurements and context associated with the diagnostic.
    #[inline]
    pub fn value<T>(mut self, value: T) -> Self
    where
        T: conjure_object::serde::Serialize,
    {
        self.value = conjure_object::Any::new(value).expect("value failed to serialize");
        self
    }
    /// Consumes the builder, constructing a new instance of the type.
    #[inline]
    pub fn build(self) -> GenericDiagnostic {
        GenericDiagnostic {
            diagnostic_type: self.diagnostic_type,
            value: self.value,
        }
    }
}
impl ser::Serialize for GenericDiagnostic {
    fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error>
    where
        S: ser::Serializer,
    {
        let size = 2usize;
        let mut s = s.serialize_struct("GenericDiagnostic", size)?;
        s.serialize_field("diagnosticType", &self.diagnostic_type)?;
        s.serialize_field("value", &self.value)?;
        s.end()
    }
}
impl<'de> de::Deserialize<'de> for GenericDiagnostic {
    fn deserialize<D>(d: D) -> Result<GenericDiagnostic, D::Error>
    where
        D: de::Deserializer<'de>,
    {
        d.deserialize_struct("GenericDiagnostic", &["diagnosticType", "value"], Visitor_)
    }
}
struct Visitor_;
impl<'de> de::Visitor<'de> for Visitor_ {
    type Value = GenericDiagnostic;
    fn expecting(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
        fmt.write_str("map")
    }
    fn visit_map<A>(self, mut map_: A) -> Result<GenericDiagnostic, A::Error>
    where
        A: de::MapAccess<'de>,
    {
        let mut diagnostic_type = None;
        let mut value = None;
        while let Some(field_) = map_.next_key()? {
            match field_ {
                Field_::DiagnosticType => diagnostic_type = Some(map_.next_value()?),
                Field_::Value => value = Some(map_.next_value()?),
                Field_::Unknown_ => {
                    map_.next_value::<de::IgnoredAny>()?;
                }
            }
        }
        let diagnostic_type = match diagnostic_type {
            Some(v) => v,
            None => return Err(de::Error::missing_field("diagnosticType")),
        };
        let value = match value {
            Some(v) => v,
            None => return Err(de::Error::missing_field("value")),
        };
        Ok(GenericDiagnostic {
            diagnostic_type,
            value,
        })
    }
}
enum Field_ {
    DiagnosticType,
    Value,
    Unknown_,
}
impl<'de> de::Deserialize<'de> for Field_ {
    fn deserialize<D>(d: D) -> Result<Field_, D::Error>
    where
        D: de::Deserializer<'de>,
    {
        d.deserialize_str(FieldVisitor_)
    }
}
struct FieldVisitor_;
impl<'de> de::Visitor<'de> for FieldVisitor_ {
    type Value = Field_;
    fn expecting(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
        fmt.write_str("string")
    }
    fn visit_str<E>(self, value: &str) -> Result<Field_, E>
    where
        E: de::Error,
    {
        let v = match value {
            "diagnosticType" => Field_::DiagnosticType,
            "value" => Field_::Value,
            _ => Field_::Unknown_,
        };
        Ok(v)
    }
}