datadog_api_client/datadogV1/model/
model_webhooks_integration_encoding.rs1use serde::{Deserialize, Deserializer, Serialize, Serializer};
6
7#[non_exhaustive]
8#[derive(Clone, Debug, Eq, PartialEq)]
9pub enum WebhooksIntegrationEncoding {
10 JSON,
11 FORM,
12 UnparsedObject(crate::datadog::UnparsedObject),
13}
14
15impl ToString for WebhooksIntegrationEncoding {
16 fn to_string(&self) -> String {
17 match self {
18 Self::JSON => String::from("json"),
19 Self::FORM => String::from("form"),
20 Self::UnparsedObject(v) => v.value.to_string(),
21 }
22 }
23}
24
25impl Serialize for WebhooksIntegrationEncoding {
26 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
27 where
28 S: Serializer,
29 {
30 match self {
31 Self::UnparsedObject(v) => v.serialize(serializer),
32 _ => serializer.serialize_str(self.to_string().as_str()),
33 }
34 }
35}
36
37impl<'de> Deserialize<'de> for WebhooksIntegrationEncoding {
38 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
39 where
40 D: Deserializer<'de>,
41 {
42 let s: String = String::deserialize(deserializer)?;
43 Ok(match s.as_str() {
44 "json" => Self::JSON,
45 "form" => Self::FORM,
46 _ => Self::UnparsedObject(crate::datadog::UnparsedObject {
47 value: serde_json::Value::String(s.into()),
48 }),
49 })
50 }
51}