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 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
use conjure_object::serde::ser::SerializeStruct as SerializeStruct_; use conjure_object::serde::{de, ser}; use std::fmt; #[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)] pub struct BackingFileSystem { file_system_id: String, base_uri: String, configuration: std::collections::BTreeMap<String, String>, } impl BackingFileSystem { #[doc = r" Constructs a new instance of the type."] #[inline] pub fn new<T, U, V>(file_system_id: T, base_uri: U, configuration: V) -> BackingFileSystem where T: Into<String>, U: Into<String>, V: IntoIterator<Item = (String, String)>, { BackingFileSystem { file_system_id: file_system_id.into(), base_uri: base_uri.into(), configuration: configuration.into_iter().collect(), } } #[doc = r" Returns a new builder."] #[inline] pub fn builder() -> Builder { Default::default() } #[doc = "The name by which this file system is identified."] #[inline] pub fn file_system_id(&self) -> &str { &*self.file_system_id } #[inline] pub fn base_uri(&self) -> &str { &*self.base_uri } #[inline] pub fn configuration(&self) -> &std::collections::BTreeMap<String, String> { &self.configuration } } #[doc = "A builder for the `BackingFileSystem` type."] #[derive(Debug, Clone, Default)] pub struct Builder { file_system_id: Option<String>, base_uri: Option<String>, configuration: std::collections::BTreeMap<String, String>, } impl Builder { #[doc = "The name by which this file system is identified."] #[doc = r""] #[doc = r" Required."] pub fn file_system_id<T>(&mut self, file_system_id: T) -> &mut Self where T: Into<String>, { self.file_system_id = Some(file_system_id.into()); self } #[doc = r""] #[doc = r" Required."] pub fn base_uri<T>(&mut self, base_uri: T) -> &mut Self where T: Into<String>, { self.base_uri = Some(base_uri.into()); self } pub fn configuration<T>(&mut self, configuration: T) -> &mut Self where T: IntoIterator<Item = (String, String)>, { self.configuration = configuration.into_iter().collect(); self } pub fn extend_configuration<T>(&mut self, configuration: T) -> &mut Self where T: IntoIterator<Item = (String, String)>, { self.configuration.extend(configuration); self } pub fn insert_configuration<K, V>(&mut self, key: K, value: V) -> &mut Self where K: Into<String>, V: Into<String>, { self.configuration.insert(key.into(), value.into()); self } #[doc = r" Constructs a new instance of the type."] #[doc = r""] #[doc = r" # Panics"] #[doc = r""] #[doc = r" Panics if a required field was not set."] #[inline] pub fn build(&self) -> BackingFileSystem { BackingFileSystem { file_system_id: self .file_system_id .clone() .expect("field file_system_id was not set"), base_uri: self.base_uri.clone().expect("field base_uri was not set"), configuration: self.configuration.clone(), } } } impl From<BackingFileSystem> for Builder { #[inline] fn from(_v: BackingFileSystem) -> Builder { Builder { file_system_id: Some(_v.file_system_id), base_uri: Some(_v.base_uri), configuration: _v.configuration, } } } impl ser::Serialize for BackingFileSystem { fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error> where S: ser::Serializer, { let mut size = 2usize; let skip_configuration = self.configuration.is_empty(); if !skip_configuration { size += 1; } let mut s = s.serialize_struct("BackingFileSystem", size)?; s.serialize_field("fileSystemId", &self.file_system_id)?; s.serialize_field("baseUri", &self.base_uri)?; if skip_configuration { s.skip_field("configuration")?; } else { s.serialize_field("configuration", &self.configuration)?; } s.end() } } impl<'de> de::Deserialize<'de> for BackingFileSystem { fn deserialize<D>(d: D) -> Result<BackingFileSystem, D::Error> where D: de::Deserializer<'de>, { d.deserialize_struct( "BackingFileSystem", &["fileSystemId", "baseUri", "configuration"], Visitor_, ) } } struct Visitor_; impl<'de> de::Visitor<'de> for Visitor_ { type Value = BackingFileSystem; fn expecting(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fmt.write_str("map") } fn visit_map<A>(self, mut map_: A) -> Result<BackingFileSystem, A::Error> where A: de::MapAccess<'de>, { let mut file_system_id = None; let mut base_uri = None; let mut configuration = None; while let Some(field_) = map_.next_key()? { match field_ { Field_::FileSystemId => file_system_id = Some(map_.next_value()?), Field_::BaseUri => base_uri = Some(map_.next_value()?), Field_::Configuration => configuration = Some(map_.next_value()?), Field_::Unknown_ => { map_.next_value::<de::IgnoredAny>()?; } } } let file_system_id = match file_system_id { Some(v) => v, None => return Err(de::Error::missing_field("fileSystemId")), }; let base_uri = match base_uri { Some(v) => v, None => return Err(de::Error::missing_field("baseUri")), }; let configuration = match configuration { Some(v) => v, None => Default::default(), }; Ok(BackingFileSystem { file_system_id, base_uri, configuration, }) } } enum Field_ { FileSystemId, BaseUri, Configuration, 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 { "fileSystemId" => Field_::FileSystemId, "baseUri" => Field_::BaseUri, "configuration" => Field_::Configuration, _ => Field_::Unknown_, }; Ok(v) } }