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

1// Generated from definition com.github.openshift.api.build.v1.ImageSourcePath
2
3/// ImageSourcePath describes a path to be copied from a source image and its destination within the build directory.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct ImageSourcePath {
6    /// destinationDir is the relative directory within the build directory where files copied from the image are placed.
7    pub destination_dir: String,
8
9    /// sourcePath is the absolute path of the file or directory inside the image to copy to the build directory.  If the source path ends in /. then the content of the directory will be copied, but the directory itself will not be created at the destination.
10    pub source_path: String,
11}
12
13impl<'de> serde::Deserialize<'de> for ImageSourcePath {
14    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
15        #[allow(non_camel_case_types)]
16        enum Field {
17            Key_destination_dir,
18            Key_source_path,
19            Other,
20        }
21
22        impl<'de> serde::Deserialize<'de> for Field {
23            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
24                struct Visitor;
25
26                impl<'de> serde::de::Visitor<'de> for Visitor {
27                    type Value = Field;
28
29                    fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
30                        f.write_str("field identifier")
31                    }
32
33                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: serde::de::Error {
34                        Ok(match v {
35                            "destinationDir" => Field::Key_destination_dir,
36                            "sourcePath" => Field::Key_source_path,
37                            _ => Field::Other,
38                        })
39                    }
40                }
41
42                deserializer.deserialize_identifier(Visitor)
43            }
44        }
45
46        struct Visitor;
47
48        impl<'de> serde::de::Visitor<'de> for Visitor {
49            type Value = ImageSourcePath;
50
51            fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
52                f.write_str("ImageSourcePath")
53            }
54
55            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: serde::de::MapAccess<'de> {
56                let mut value_destination_dir: Option<String> = None;
57                let mut value_source_path: Option<String> = None;
58
59                while let Some(key) = serde::de::MapAccess::next_key::<Field>(&mut map)? {
60                    match key {
61                        Field::Key_destination_dir => value_destination_dir = Some(serde::de::MapAccess::next_value(&mut map)?),
62                        Field::Key_source_path => value_source_path = Some(serde::de::MapAccess::next_value(&mut map)?),
63                        Field::Other => { let _: serde::de::IgnoredAny = serde::de::MapAccess::next_value(&mut map)?; },
64                    }
65                }
66
67                Ok(ImageSourcePath {
68                    destination_dir: value_destination_dir.ok_or_else(|| serde::de::Error::missing_field("destinationDir"))?,
69                    source_path: value_source_path.ok_or_else(|| serde::de::Error::missing_field("sourcePath"))?,
70                })
71            }
72        }
73
74        deserializer.deserialize_struct(
75            "ImageSourcePath",
76            &[
77                "destinationDir",
78                "sourcePath",
79            ],
80            Visitor,
81        )
82    }
83}
84
85impl serde::Serialize for ImageSourcePath {
86    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
87        let mut state = serializer.serialize_struct(
88            "ImageSourcePath",
89            2,
90        )?;
91        serde::ser::SerializeStruct::serialize_field(&mut state, "destinationDir", &self.destination_dir)?;
92        serde::ser::SerializeStruct::serialize_field(&mut state, "sourcePath", &self.source_path)?;
93        serde::ser::SerializeStruct::end(state)
94    }
95}