openshift_openapi/v4_5/api/build/v1/
source_strategy_options.rs

1// Generated from definition com.github.openshift.api.build.v1.SourceStrategyOptions
2
3/// SourceStrategyOptions contains extra strategy options for Source builds
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct SourceStrategyOptions {
6    /// incremental overrides the source-strategy incremental option in the build config
7    pub incremental: Option<bool>,
8}
9
10impl<'de> serde::Deserialize<'de> for SourceStrategyOptions {
11    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
12        #[allow(non_camel_case_types)]
13        enum Field {
14            Key_incremental,
15            Other,
16        }
17
18        impl<'de> serde::Deserialize<'de> for Field {
19            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
20                struct Visitor;
21
22                impl<'de> serde::de::Visitor<'de> for Visitor {
23                    type Value = Field;
24
25                    fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
26                        f.write_str("field identifier")
27                    }
28
29                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: serde::de::Error {
30                        Ok(match v {
31                            "incremental" => Field::Key_incremental,
32                            _ => Field::Other,
33                        })
34                    }
35                }
36
37                deserializer.deserialize_identifier(Visitor)
38            }
39        }
40
41        struct Visitor;
42
43        impl<'de> serde::de::Visitor<'de> for Visitor {
44            type Value = SourceStrategyOptions;
45
46            fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
47                f.write_str("SourceStrategyOptions")
48            }
49
50            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: serde::de::MapAccess<'de> {
51                let mut value_incremental: Option<bool> = None;
52
53                while let Some(key) = serde::de::MapAccess::next_key::<Field>(&mut map)? {
54                    match key {
55                        Field::Key_incremental => value_incremental = serde::de::MapAccess::next_value(&mut map)?,
56                        Field::Other => { let _: serde::de::IgnoredAny = serde::de::MapAccess::next_value(&mut map)?; },
57                    }
58                }
59
60                Ok(SourceStrategyOptions {
61                    incremental: value_incremental,
62                })
63            }
64        }
65
66        deserializer.deserialize_struct(
67            "SourceStrategyOptions",
68            &[
69                "incremental",
70            ],
71            Visitor,
72        )
73    }
74}
75
76impl serde::Serialize for SourceStrategyOptions {
77    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
78        let mut state = serializer.serialize_struct(
79            "SourceStrategyOptions",
80            self.incremental.as_ref().map_or(0, |_| 1),
81        )?;
82        if let Some(value) = &self.incremental {
83            serde::ser::SerializeStruct::serialize_field(&mut state, "incremental", value)?;
84        }
85        serde::ser::SerializeStruct::end(state)
86    }
87}