r1_api_layer/
models.rs

1#![allow(unused_qualifications)]
2
3use validator::Validate;
4
5#[cfg(any(feature = "client", feature = "server"))]
6use crate::header;
7use crate::models;
8
9#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
10#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
11pub struct Click {
12    #[serde(rename = "Point")]
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub point: Option<models::Point>,
15
16    #[serde(rename = "time")]
17    #[serde(skip_serializing_if = "Option::is_none")]
18    pub time: Option<i32>,
19}
20
21impl Click {
22    #[allow(clippy::new_without_default)]
23    pub fn new() -> Click {
24        Click {
25            point: None,
26            time: None,
27        }
28    }
29}
30
31/// Converts the Click value to the Query Parameters representation (style=form, explode=false)
32/// specified in https://swagger.io/docs/specification/serialization/
33/// Should be implemented in a serde serializer
34impl std::string::ToString for Click {
35    fn to_string(&self) -> String {
36        let params: Vec<Option<String>> = vec![
37            // Skipping non-primitive type Point in query parameter serialization
38            self.time
39                .as_ref()
40                .map(|time| ["time".to_string(), time.to_string()].join(",")),
41        ];
42
43        params.into_iter().flatten().collect::<Vec<_>>().join(",")
44    }
45}
46
47/// Converts Query Parameters representation (style=form, explode=false) to a Click value
48/// as specified in https://swagger.io/docs/specification/serialization/
49/// Should be implemented in a serde deserializer
50impl std::str::FromStr for Click {
51    type Err = String;
52
53    fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
54        /// An intermediate representation of the struct to use for parsing.
55        #[derive(Default)]
56        #[allow(dead_code)]
57        struct IntermediateRep {
58            pub point: Vec<models::Point>,
59            pub time: Vec<i32>,
60        }
61
62        let mut intermediate_rep = IntermediateRep::default();
63
64        // Parse into intermediate representation
65        let mut string_iter = s.split(',');
66        let mut key_result = string_iter.next();
67
68        while key_result.is_some() {
69            let val = match string_iter.next() {
70                Some(x) => x,
71                None => {
72                    return std::result::Result::Err(
73                        "Missing value while parsing Click".to_string(),
74                    )
75                }
76            };
77
78            if let Some(key) = key_result {
79                #[allow(clippy::match_single_binding)]
80                match key {
81                    #[allow(clippy::redundant_clone)]
82                    "Point" => intermediate_rep.point.push(
83                        <models::Point as std::str::FromStr>::from_str(val)
84                            .map_err(|x| x.to_string())?,
85                    ),
86                    #[allow(clippy::redundant_clone)]
87                    "time" => intermediate_rep.time.push(
88                        <i32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?,
89                    ),
90                    _ => {
91                        return std::result::Result::Err(
92                            "Unexpected key while parsing Click".to_string(),
93                        )
94                    }
95                }
96            }
97
98            // Get the next key
99            key_result = string_iter.next();
100        }
101
102        // Use the intermediate representation to return the struct
103        std::result::Result::Ok(Click {
104            point: intermediate_rep.point.into_iter().next(),
105            time: intermediate_rep.time.into_iter().next(),
106        })
107    }
108}
109
110// Methods for converting between header::IntoHeaderValue<Click> and hyper::header::HeaderValue
111
112#[cfg(any(feature = "client", feature = "server"))]
113impl std::convert::TryFrom<header::IntoHeaderValue<Click>> for hyper::header::HeaderValue {
114    type Error = String;
115
116    fn try_from(
117        hdr_value: header::IntoHeaderValue<Click>,
118    ) -> std::result::Result<Self, Self::Error> {
119        let hdr_value = hdr_value.to_string();
120        match hyper::header::HeaderValue::from_str(&hdr_value) {
121            std::result::Result::Ok(value) => std::result::Result::Ok(value),
122            std::result::Result::Err(e) => std::result::Result::Err(format!(
123                "Invalid header value for Click - value: {} is invalid {}",
124                hdr_value, e
125            )),
126        }
127    }
128}
129
130#[cfg(any(feature = "client", feature = "server"))]
131impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<Click> {
132    type Error = String;
133
134    fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
135        match hdr_value.to_str() {
136            std::result::Result::Ok(value) => match <Click as std::str::FromStr>::from_str(value) {
137                std::result::Result::Ok(value) => {
138                    std::result::Result::Ok(header::IntoHeaderValue(value))
139                }
140                std::result::Result::Err(err) => std::result::Result::Err(format!(
141                    "Unable to convert header value '{}' into Click - {}",
142                    value, err
143                )),
144            },
145            std::result::Result::Err(e) => std::result::Result::Err(format!(
146                "Unable to convert header: {:?} to string: {}",
147                hdr_value, e
148            )),
149        }
150    }
151}
152
153#[cfg(feature = "server")]
154impl std::convert::TryFrom<header::IntoHeaderValue<Vec<Click>>> for hyper::header::HeaderValue {
155    type Error = String;
156
157    fn try_from(
158        hdr_values: header::IntoHeaderValue<Vec<Click>>,
159    ) -> std::result::Result<Self, Self::Error> {
160        let hdr_values: Vec<String> = hdr_values
161            .0
162            .into_iter()
163            .map(|hdr_value| hdr_value.to_string())
164            .collect();
165
166        match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) {
167            std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value),
168            std::result::Result::Err(e) => std::result::Result::Err(format!(
169                "Unable to convert {:?} into a header - {}",
170                hdr_values, e
171            )),
172        }
173    }
174}
175
176#[cfg(feature = "server")]
177impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<Vec<Click>> {
178    type Error = String;
179
180    fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
181        match hdr_values.to_str() {
182            std::result::Result::Ok(hdr_values) => {
183                let hdr_values: std::vec::Vec<Click> = hdr_values
184                    .split(',')
185                    .filter_map(|hdr_value| match hdr_value.trim() {
186                        "" => std::option::Option::None,
187                        hdr_value => std::option::Option::Some({
188                            match <Click as std::str::FromStr>::from_str(hdr_value) {
189                                std::result::Result::Ok(value) => std::result::Result::Ok(value),
190                                std::result::Result::Err(err) => std::result::Result::Err(format!(
191                                    "Unable to convert header value '{}' into Click - {}",
192                                    hdr_value, err
193                                )),
194                            }
195                        }),
196                    })
197                    .collect::<std::result::Result<std::vec::Vec<_>, String>>()?;
198
199                std::result::Result::Ok(header::IntoHeaderValue(hdr_values))
200            }
201            std::result::Result::Err(e) => std::result::Result::Err(format!(
202                "Unable to parse header: {:?} as a string - {}",
203                hdr_values, e
204            )),
205        }
206    }
207}
208
209#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
210#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
211pub struct CreateUserDto {
212    #[serde(rename = "UUID")]
213    #[serde(skip_serializing_if = "Option::is_none")]
214    pub uuid: Option<String>,
215
216    #[serde(rename = "userName")]
217    #[serde(skip_serializing_if = "Option::is_none")]
218    pub user_name: Option<String>,
219
220    #[serde(rename = "profilePicture")]
221    #[serde(skip_serializing_if = "Option::is_none")]
222    pub profile_picture: Option<String>,
223}
224
225impl CreateUserDto {
226    #[allow(clippy::new_without_default)]
227    pub fn new() -> CreateUserDto {
228        CreateUserDto {
229            uuid: None,
230            user_name: None,
231            profile_picture: None,
232        }
233    }
234}
235
236/// Converts the CreateUserDto value to the Query Parameters representation (style=form, explode=false)
237/// specified in https://swagger.io/docs/specification/serialization/
238/// Should be implemented in a serde serializer
239impl std::string::ToString for CreateUserDto {
240    fn to_string(&self) -> String {
241        let params: Vec<Option<String>> = vec![
242            self.uuid
243                .as_ref()
244                .map(|uuid| ["UUID".to_string(), uuid.to_string()].join(",")),
245            self.user_name
246                .as_ref()
247                .map(|user_name| ["userName".to_string(), user_name.to_string()].join(",")),
248            self.profile_picture.as_ref().map(|profile_picture| {
249                ["profilePicture".to_string(), profile_picture.to_string()].join(",")
250            }),
251        ];
252
253        params.into_iter().flatten().collect::<Vec<_>>().join(",")
254    }
255}
256
257/// Converts Query Parameters representation (style=form, explode=false) to a CreateUserDto value
258/// as specified in https://swagger.io/docs/specification/serialization/
259/// Should be implemented in a serde deserializer
260impl std::str::FromStr for CreateUserDto {
261    type Err = String;
262
263    fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
264        /// An intermediate representation of the struct to use for parsing.
265        #[derive(Default)]
266        #[allow(dead_code)]
267        struct IntermediateRep {
268            pub uuid: Vec<String>,
269            pub user_name: Vec<String>,
270            pub profile_picture: Vec<String>,
271        }
272
273        let mut intermediate_rep = IntermediateRep::default();
274
275        // Parse into intermediate representation
276        let mut string_iter = s.split(',');
277        let mut key_result = string_iter.next();
278
279        while key_result.is_some() {
280            let val = match string_iter.next() {
281                Some(x) => x,
282                None => {
283                    return std::result::Result::Err(
284                        "Missing value while parsing CreateUserDto".to_string(),
285                    )
286                }
287            };
288
289            if let Some(key) = key_result {
290                #[allow(clippy::match_single_binding)]
291                match key {
292                    #[allow(clippy::redundant_clone)]
293                    "UUID" => intermediate_rep.uuid.push(
294                        <String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?,
295                    ),
296                    #[allow(clippy::redundant_clone)]
297                    "userName" => intermediate_rep.user_name.push(
298                        <String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?,
299                    ),
300                    #[allow(clippy::redundant_clone)]
301                    "profilePicture" => intermediate_rep.profile_picture.push(
302                        <String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?,
303                    ),
304                    _ => {
305                        return std::result::Result::Err(
306                            "Unexpected key while parsing CreateUserDto".to_string(),
307                        )
308                    }
309                }
310            }
311
312            // Get the next key
313            key_result = string_iter.next();
314        }
315
316        // Use the intermediate representation to return the struct
317        std::result::Result::Ok(CreateUserDto {
318            uuid: intermediate_rep.uuid.into_iter().next(),
319            user_name: intermediate_rep.user_name.into_iter().next(),
320            profile_picture: intermediate_rep.profile_picture.into_iter().next(),
321        })
322    }
323}
324
325// Methods for converting between header::IntoHeaderValue<CreateUserDto> and hyper::header::HeaderValue
326
327#[cfg(any(feature = "client", feature = "server"))]
328impl std::convert::TryFrom<header::IntoHeaderValue<CreateUserDto>> for hyper::header::HeaderValue {
329    type Error = String;
330
331    fn try_from(
332        hdr_value: header::IntoHeaderValue<CreateUserDto>,
333    ) -> std::result::Result<Self, Self::Error> {
334        let hdr_value = hdr_value.to_string();
335        match hyper::header::HeaderValue::from_str(&hdr_value) {
336            std::result::Result::Ok(value) => std::result::Result::Ok(value),
337            std::result::Result::Err(e) => std::result::Result::Err(format!(
338                "Invalid header value for CreateUserDto - value: {} is invalid {}",
339                hdr_value, e
340            )),
341        }
342    }
343}
344
345#[cfg(any(feature = "client", feature = "server"))]
346impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<CreateUserDto> {
347    type Error = String;
348
349    fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
350        match hdr_value.to_str() {
351            std::result::Result::Ok(value) => {
352                match <CreateUserDto as std::str::FromStr>::from_str(value) {
353                    std::result::Result::Ok(value) => {
354                        std::result::Result::Ok(header::IntoHeaderValue(value))
355                    }
356                    std::result::Result::Err(err) => std::result::Result::Err(format!(
357                        "Unable to convert header value '{}' into CreateUserDto - {}",
358                        value, err
359                    )),
360                }
361            }
362            std::result::Result::Err(e) => std::result::Result::Err(format!(
363                "Unable to convert header: {:?} to string: {}",
364                hdr_value, e
365            )),
366        }
367    }
368}
369
370#[cfg(feature = "server")]
371impl std::convert::TryFrom<header::IntoHeaderValue<Vec<CreateUserDto>>>
372    for hyper::header::HeaderValue
373{
374    type Error = String;
375
376    fn try_from(
377        hdr_values: header::IntoHeaderValue<Vec<CreateUserDto>>,
378    ) -> std::result::Result<Self, Self::Error> {
379        let hdr_values: Vec<String> = hdr_values
380            .0
381            .into_iter()
382            .map(|hdr_value| hdr_value.to_string())
383            .collect();
384
385        match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) {
386            std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value),
387            std::result::Result::Err(e) => std::result::Result::Err(format!(
388                "Unable to convert {:?} into a header - {}",
389                hdr_values, e
390            )),
391        }
392    }
393}
394
395#[cfg(feature = "server")]
396impl std::convert::TryFrom<hyper::header::HeaderValue>
397    for header::IntoHeaderValue<Vec<CreateUserDto>>
398{
399    type Error = String;
400
401    fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
402        match hdr_values.to_str() {
403            std::result::Result::Ok(hdr_values) => {
404                let hdr_values: std::vec::Vec<CreateUserDto> = hdr_values
405                    .split(',')
406                    .filter_map(|hdr_value| match hdr_value.trim() {
407                        "" => std::option::Option::None,
408                        hdr_value => std::option::Option::Some({
409                            match <CreateUserDto as std::str::FromStr>::from_str(hdr_value) {
410                                std::result::Result::Ok(value) => std::result::Result::Ok(value),
411                                std::result::Result::Err(err) => std::result::Result::Err(format!(
412                                    "Unable to convert header value '{}' into CreateUserDto - {}",
413                                    hdr_value, err
414                                )),
415                            }
416                        }),
417                    })
418                    .collect::<std::result::Result<std::vec::Vec<_>, String>>()?;
419
420                std::result::Result::Ok(header::IntoHeaderValue(hdr_values))
421            }
422            std::result::Result::Err(e) => std::result::Result::Err(format!(
423                "Unable to parse header: {:?} as a string - {}",
424                hdr_values, e
425            )),
426        }
427    }
428}
429
430#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
431#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
432pub struct GameEndDto {
433    #[serde(rename = "UUID")]
434    #[serde(skip_serializing_if = "Option::is_none")]
435    pub uuid: Option<uuid::Uuid>,
436
437    #[serde(rename = "GameTime")]
438    #[serde(skip_serializing_if = "Option::is_none")]
439    pub game_time: Option<i32>,
440
441    #[serde(rename = "SpawnPoints")]
442    #[serde(skip_serializing_if = "Option::is_none")]
443    pub spawn_points: Option<Vec<models::Spawn>>,
444
445    #[serde(rename = "ClickPoints")]
446    #[serde(skip_serializing_if = "Option::is_none")]
447    pub click_points: Option<Vec<models::Click>>,
448
449    #[serde(rename = "difficulty")]
450    #[serde(skip_serializing_if = "Option::is_none")]
451    pub difficulty: Option<models::GameEndDtoDifficulty>,
452}
453
454impl GameEndDto {
455    #[allow(clippy::new_without_default)]
456    pub fn new() -> GameEndDto {
457        GameEndDto {
458            uuid: None,
459            game_time: None,
460            spawn_points: None,
461            click_points: None,
462            difficulty: None,
463        }
464    }
465}
466
467/// Converts the GameEndDto value to the Query Parameters representation (style=form, explode=false)
468/// specified in https://swagger.io/docs/specification/serialization/
469/// Should be implemented in a serde serializer
470impl std::string::ToString for GameEndDto {
471    fn to_string(&self) -> String {
472        let params: Vec<Option<String>> = vec![
473            // Skipping non-primitive type UUID in query parameter serialization
474            self.game_time
475                .as_ref()
476                .map(|game_time| ["GameTime".to_string(), game_time.to_string()].join(",")),
477            // Skipping non-primitive type SpawnPoints in query parameter serialization
478            // Skipping non-primitive type ClickPoints in query parameter serialization
479            // Skipping non-primitive type difficulty in query parameter serialization
480        ];
481
482        params.into_iter().flatten().collect::<Vec<_>>().join(",")
483    }
484}
485
486/// Converts Query Parameters representation (style=form, explode=false) to a GameEndDto value
487/// as specified in https://swagger.io/docs/specification/serialization/
488/// Should be implemented in a serde deserializer
489impl std::str::FromStr for GameEndDto {
490    type Err = String;
491
492    fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
493        /// An intermediate representation of the struct to use for parsing.
494        #[derive(Default)]
495        #[allow(dead_code)]
496        struct IntermediateRep {
497            pub uuid: Vec<uuid::Uuid>,
498            pub game_time: Vec<i32>,
499            pub spawn_points: Vec<Vec<models::Spawn>>,
500            pub click_points: Vec<Vec<models::Click>>,
501            pub difficulty: Vec<models::GameEndDtoDifficulty>,
502        }
503
504        let mut intermediate_rep = IntermediateRep::default();
505
506        // Parse into intermediate representation
507        let mut string_iter = s.split(',');
508        let mut key_result = string_iter.next();
509
510        while key_result.is_some() {
511            let val = match string_iter.next() {
512                Some(x) => x,
513                None => {
514                    return std::result::Result::Err(
515                        "Missing value while parsing GameEndDto".to_string(),
516                    )
517                }
518            };
519
520            if let Some(key) = key_result {
521                #[allow(clippy::match_single_binding)]
522                match key {
523                    #[allow(clippy::redundant_clone)]
524                    "UUID" => intermediate_rep.uuid.push(
525                        <uuid::Uuid as std::str::FromStr>::from_str(val)
526                            .map_err(|x| x.to_string())?,
527                    ),
528                    #[allow(clippy::redundant_clone)]
529                    "GameTime" => intermediate_rep.game_time.push(
530                        <i32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?,
531                    ),
532                    "SpawnPoints" => {
533                        return std::result::Result::Err(
534                            "Parsing a container in this style is not supported in GameEndDto"
535                                .to_string(),
536                        )
537                    }
538                    "ClickPoints" => {
539                        return std::result::Result::Err(
540                            "Parsing a container in this style is not supported in GameEndDto"
541                                .to_string(),
542                        )
543                    }
544                    #[allow(clippy::redundant_clone)]
545                    "difficulty" => intermediate_rep.difficulty.push(
546                        <models::GameEndDtoDifficulty as std::str::FromStr>::from_str(val)
547                            .map_err(|x| x.to_string())?,
548                    ),
549                    _ => {
550                        return std::result::Result::Err(
551                            "Unexpected key while parsing GameEndDto".to_string(),
552                        )
553                    }
554                }
555            }
556
557            // Get the next key
558            key_result = string_iter.next();
559        }
560
561        // Use the intermediate representation to return the struct
562        std::result::Result::Ok(GameEndDto {
563            uuid: intermediate_rep.uuid.into_iter().next(),
564            game_time: intermediate_rep.game_time.into_iter().next(),
565            spawn_points: intermediate_rep.spawn_points.into_iter().next(),
566            click_points: intermediate_rep.click_points.into_iter().next(),
567            difficulty: intermediate_rep.difficulty.into_iter().next(),
568        })
569    }
570}
571
572// Methods for converting between header::IntoHeaderValue<GameEndDto> and hyper::header::HeaderValue
573
574#[cfg(any(feature = "client", feature = "server"))]
575impl std::convert::TryFrom<header::IntoHeaderValue<GameEndDto>> for hyper::header::HeaderValue {
576    type Error = String;
577
578    fn try_from(
579        hdr_value: header::IntoHeaderValue<GameEndDto>,
580    ) -> std::result::Result<Self, Self::Error> {
581        let hdr_value = hdr_value.to_string();
582        match hyper::header::HeaderValue::from_str(&hdr_value) {
583            std::result::Result::Ok(value) => std::result::Result::Ok(value),
584            std::result::Result::Err(e) => std::result::Result::Err(format!(
585                "Invalid header value for GameEndDto - value: {} is invalid {}",
586                hdr_value, e
587            )),
588        }
589    }
590}
591
592#[cfg(any(feature = "client", feature = "server"))]
593impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<GameEndDto> {
594    type Error = String;
595
596    fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
597        match hdr_value.to_str() {
598            std::result::Result::Ok(value) => {
599                match <GameEndDto as std::str::FromStr>::from_str(value) {
600                    std::result::Result::Ok(value) => {
601                        std::result::Result::Ok(header::IntoHeaderValue(value))
602                    }
603                    std::result::Result::Err(err) => std::result::Result::Err(format!(
604                        "Unable to convert header value '{}' into GameEndDto - {}",
605                        value, err
606                    )),
607                }
608            }
609            std::result::Result::Err(e) => std::result::Result::Err(format!(
610                "Unable to convert header: {:?} to string: {}",
611                hdr_value, e
612            )),
613        }
614    }
615}
616
617#[cfg(feature = "server")]
618impl std::convert::TryFrom<header::IntoHeaderValue<Vec<GameEndDto>>>
619    for hyper::header::HeaderValue
620{
621    type Error = String;
622
623    fn try_from(
624        hdr_values: header::IntoHeaderValue<Vec<GameEndDto>>,
625    ) -> std::result::Result<Self, Self::Error> {
626        let hdr_values: Vec<String> = hdr_values
627            .0
628            .into_iter()
629            .map(|hdr_value| hdr_value.to_string())
630            .collect();
631
632        match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) {
633            std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value),
634            std::result::Result::Err(e) => std::result::Result::Err(format!(
635                "Unable to convert {:?} into a header - {}",
636                hdr_values, e
637            )),
638        }
639    }
640}
641
642#[cfg(feature = "server")]
643impl std::convert::TryFrom<hyper::header::HeaderValue>
644    for header::IntoHeaderValue<Vec<GameEndDto>>
645{
646    type Error = String;
647
648    fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
649        match hdr_values.to_str() {
650            std::result::Result::Ok(hdr_values) => {
651                let hdr_values: std::vec::Vec<GameEndDto> = hdr_values
652                    .split(',')
653                    .filter_map(|hdr_value| match hdr_value.trim() {
654                        "" => std::option::Option::None,
655                        hdr_value => std::option::Option::Some({
656                            match <GameEndDto as std::str::FromStr>::from_str(hdr_value) {
657                                std::result::Result::Ok(value) => std::result::Result::Ok(value),
658                                std::result::Result::Err(err) => std::result::Result::Err(format!(
659                                    "Unable to convert header value '{}' into GameEndDto - {}",
660                                    hdr_value, err
661                                )),
662                            }
663                        }),
664                    })
665                    .collect::<std::result::Result<std::vec::Vec<_>, String>>()?;
666
667                std::result::Result::Ok(header::IntoHeaderValue(hdr_values))
668            }
669            std::result::Result::Err(e) => std::result::Result::Err(format!(
670                "Unable to parse header: {:?} as a string - {}",
671                hdr_values, e
672            )),
673        }
674    }
675}
676
677/// Enumeration of values.
678/// Since this enum's variants do not hold data, we can easily define them as `#[repr(C)]`
679/// which helps with FFI.
680#[allow(non_camel_case_types)]
681#[repr(C)]
682#[derive(
683    Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize, Hash,
684)]
685#[cfg_attr(feature = "conversion", derive(frunk_enum_derive::LabelledGenericEnum))]
686pub enum GameEndDtoDifficulty {
687    #[serde(rename = "Easy")]
688    Easy,
689    #[serde(rename = "Medium")]
690    Medium,
691    #[serde(rename = "Hard")]
692    Hard,
693    #[serde(rename = "Expert")]
694    Expert,
695}
696
697impl std::fmt::Display for GameEndDtoDifficulty {
698    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
699        match *self {
700            GameEndDtoDifficulty::Easy => write!(f, "Easy"),
701            GameEndDtoDifficulty::Medium => write!(f, "Medium"),
702            GameEndDtoDifficulty::Hard => write!(f, "Hard"),
703            GameEndDtoDifficulty::Expert => write!(f, "Expert"),
704        }
705    }
706}
707
708impl std::str::FromStr for GameEndDtoDifficulty {
709    type Err = String;
710
711    fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
712        match s {
713            "Easy" => std::result::Result::Ok(GameEndDtoDifficulty::Easy),
714            "Medium" => std::result::Result::Ok(GameEndDtoDifficulty::Medium),
715            "Hard" => std::result::Result::Ok(GameEndDtoDifficulty::Hard),
716            "Expert" => std::result::Result::Ok(GameEndDtoDifficulty::Expert),
717            _ => std::result::Result::Err(format!("Value not valid: {}", s)),
718        }
719    }
720}
721
722// Methods for converting between header::IntoHeaderValue<GameEndDtoDifficulty> and hyper::header::HeaderValue
723
724#[cfg(any(feature = "client", feature = "server"))]
725impl std::convert::TryFrom<header::IntoHeaderValue<GameEndDtoDifficulty>>
726    for hyper::header::HeaderValue
727{
728    type Error = String;
729
730    fn try_from(
731        hdr_value: header::IntoHeaderValue<GameEndDtoDifficulty>,
732    ) -> std::result::Result<Self, Self::Error> {
733        let hdr_value = hdr_value.to_string();
734        match hyper::header::HeaderValue::from_str(&hdr_value) {
735            std::result::Result::Ok(value) => std::result::Result::Ok(value),
736            std::result::Result::Err(e) => std::result::Result::Err(format!(
737                "Invalid header value for GameEndDtoDifficulty - value: {} is invalid {}",
738                hdr_value, e
739            )),
740        }
741    }
742}
743
744#[cfg(any(feature = "client", feature = "server"))]
745impl std::convert::TryFrom<hyper::header::HeaderValue>
746    for header::IntoHeaderValue<GameEndDtoDifficulty>
747{
748    type Error = String;
749
750    fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
751        match hdr_value.to_str() {
752            std::result::Result::Ok(value) => {
753                match <GameEndDtoDifficulty as std::str::FromStr>::from_str(value) {
754                    std::result::Result::Ok(value) => {
755                        std::result::Result::Ok(header::IntoHeaderValue(value))
756                    }
757                    std::result::Result::Err(err) => std::result::Result::Err(format!(
758                        "Unable to convert header value '{}' into GameEndDtoDifficulty - {}",
759                        value, err
760                    )),
761                }
762            }
763            std::result::Result::Err(e) => std::result::Result::Err(format!(
764                "Unable to convert header: {:?} to string: {}",
765                hdr_value, e
766            )),
767        }
768    }
769}
770
771#[cfg(feature = "server")]
772impl std::convert::TryFrom<header::IntoHeaderValue<Vec<GameEndDtoDifficulty>>>
773    for hyper::header::HeaderValue
774{
775    type Error = String;
776
777    fn try_from(
778        hdr_values: header::IntoHeaderValue<Vec<GameEndDtoDifficulty>>,
779    ) -> std::result::Result<Self, Self::Error> {
780        let hdr_values: Vec<String> = hdr_values
781            .0
782            .into_iter()
783            .map(|hdr_value| hdr_value.to_string())
784            .collect();
785
786        match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) {
787            std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value),
788            std::result::Result::Err(e) => std::result::Result::Err(format!(
789                "Unable to convert {:?} into a header - {}",
790                hdr_values, e
791            )),
792        }
793    }
794}
795
796#[cfg(feature = "server")]
797impl std::convert::TryFrom<hyper::header::HeaderValue>
798    for header::IntoHeaderValue<Vec<GameEndDtoDifficulty>>
799{
800    type Error = String;
801
802    fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
803        match hdr_values.to_str() {
804            std::result::Result::Ok(hdr_values) => {
805                let hdr_values : std::vec::Vec<GameEndDtoDifficulty> = hdr_values
806                .split(',')
807                .filter_map(|hdr_value| match hdr_value.trim() {
808                    "" => std::option::Option::None,
809                    hdr_value => std::option::Option::Some({
810                        match <GameEndDtoDifficulty as std::str::FromStr>::from_str(hdr_value) {
811                            std::result::Result::Ok(value) => std::result::Result::Ok(value),
812                            std::result::Result::Err(err) => std::result::Result::Err(
813                                format!("Unable to convert header value '{}' into GameEndDtoDifficulty - {}",
814                                    hdr_value, err))
815                        }
816                    })
817                }).collect::<std::result::Result<std::vec::Vec<_>, String>>()?;
818
819                std::result::Result::Ok(header::IntoHeaderValue(hdr_values))
820            }
821            std::result::Result::Err(e) => std::result::Result::Err(format!(
822                "Unable to parse header: {:?} as a string - {}",
823                hdr_values, e
824            )),
825        }
826    }
827}
828
829#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
830#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
831pub struct HitDetail {
832    #[serde(rename = "offset")]
833    #[serde(skip_serializing_if = "Option::is_none")]
834    pub offset: Option<Vec<i32>>,
835
836    #[serde(rename = "miss")]
837    #[serde(skip_serializing_if = "Option::is_none")]
838    pub miss: Option<Vec<models::Click>>,
839}
840
841impl HitDetail {
842    #[allow(clippy::new_without_default)]
843    pub fn new() -> HitDetail {
844        HitDetail {
845            offset: None,
846            miss: None,
847        }
848    }
849}
850
851/// Converts the HitDetail value to the Query Parameters representation (style=form, explode=false)
852/// specified in https://swagger.io/docs/specification/serialization/
853/// Should be implemented in a serde serializer
854impl std::string::ToString for HitDetail {
855    fn to_string(&self) -> String {
856        let params: Vec<Option<String>> = vec![
857            self.offset.as_ref().map(|offset| {
858                [
859                    "offset".to_string(),
860                    offset
861                        .iter()
862                        .map(|x| x.to_string())
863                        .collect::<Vec<_>>()
864                        .join(","),
865                ]
866                .join(",")
867            }),
868            // Skipping non-primitive type miss in query parameter serialization
869        ];
870
871        params.into_iter().flatten().collect::<Vec<_>>().join(",")
872    }
873}
874
875/// Converts Query Parameters representation (style=form, explode=false) to a HitDetail value
876/// as specified in https://swagger.io/docs/specification/serialization/
877/// Should be implemented in a serde deserializer
878impl std::str::FromStr for HitDetail {
879    type Err = String;
880
881    fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
882        /// An intermediate representation of the struct to use for parsing.
883        #[derive(Default)]
884        #[allow(dead_code)]
885        struct IntermediateRep {
886            pub offset: Vec<Vec<i32>>,
887            pub miss: Vec<Vec<models::Click>>,
888        }
889
890        let mut intermediate_rep = IntermediateRep::default();
891
892        // Parse into intermediate representation
893        let mut string_iter = s.split(',');
894        let mut key_result = string_iter.next();
895
896        while key_result.is_some() {
897            let val = match string_iter.next() {
898                Some(x) => x,
899                None => {
900                    return std::result::Result::Err(
901                        "Missing value while parsing HitDetail".to_string(),
902                    )
903                }
904            };
905
906            if let Some(key) = key_result {
907                #[allow(clippy::match_single_binding)]
908                match key {
909                    "offset" => {
910                        return std::result::Result::Err(
911                            "Parsing a container in this style is not supported in HitDetail"
912                                .to_string(),
913                        )
914                    }
915                    "miss" => {
916                        return std::result::Result::Err(
917                            "Parsing a container in this style is not supported in HitDetail"
918                                .to_string(),
919                        )
920                    }
921                    _ => {
922                        return std::result::Result::Err(
923                            "Unexpected key while parsing HitDetail".to_string(),
924                        )
925                    }
926                }
927            }
928
929            // Get the next key
930            key_result = string_iter.next();
931        }
932
933        // Use the intermediate representation to return the struct
934        std::result::Result::Ok(HitDetail {
935            offset: intermediate_rep.offset.into_iter().next(),
936            miss: intermediate_rep.miss.into_iter().next(),
937        })
938    }
939}
940
941// Methods for converting between header::IntoHeaderValue<HitDetail> and hyper::header::HeaderValue
942
943#[cfg(any(feature = "client", feature = "server"))]
944impl std::convert::TryFrom<header::IntoHeaderValue<HitDetail>> for hyper::header::HeaderValue {
945    type Error = String;
946
947    fn try_from(
948        hdr_value: header::IntoHeaderValue<HitDetail>,
949    ) -> std::result::Result<Self, Self::Error> {
950        let hdr_value = hdr_value.to_string();
951        match hyper::header::HeaderValue::from_str(&hdr_value) {
952            std::result::Result::Ok(value) => std::result::Result::Ok(value),
953            std::result::Result::Err(e) => std::result::Result::Err(format!(
954                "Invalid header value for HitDetail - value: {} is invalid {}",
955                hdr_value, e
956            )),
957        }
958    }
959}
960
961#[cfg(any(feature = "client", feature = "server"))]
962impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<HitDetail> {
963    type Error = String;
964
965    fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
966        match hdr_value.to_str() {
967            std::result::Result::Ok(value) => {
968                match <HitDetail as std::str::FromStr>::from_str(value) {
969                    std::result::Result::Ok(value) => {
970                        std::result::Result::Ok(header::IntoHeaderValue(value))
971                    }
972                    std::result::Result::Err(err) => std::result::Result::Err(format!(
973                        "Unable to convert header value '{}' into HitDetail - {}",
974                        value, err
975                    )),
976                }
977            }
978            std::result::Result::Err(e) => std::result::Result::Err(format!(
979                "Unable to convert header: {:?} to string: {}",
980                hdr_value, e
981            )),
982        }
983    }
984}
985
986#[cfg(feature = "server")]
987impl std::convert::TryFrom<header::IntoHeaderValue<Vec<HitDetail>>> for hyper::header::HeaderValue {
988    type Error = String;
989
990    fn try_from(
991        hdr_values: header::IntoHeaderValue<Vec<HitDetail>>,
992    ) -> std::result::Result<Self, Self::Error> {
993        let hdr_values: Vec<String> = hdr_values
994            .0
995            .into_iter()
996            .map(|hdr_value| hdr_value.to_string())
997            .collect();
998
999        match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) {
1000            std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value),
1001            std::result::Result::Err(e) => std::result::Result::Err(format!(
1002                "Unable to convert {:?} into a header - {}",
1003                hdr_values, e
1004            )),
1005        }
1006    }
1007}
1008
1009#[cfg(feature = "server")]
1010impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<Vec<HitDetail>> {
1011    type Error = String;
1012
1013    fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
1014        match hdr_values.to_str() {
1015            std::result::Result::Ok(hdr_values) => {
1016                let hdr_values: std::vec::Vec<HitDetail> = hdr_values
1017                    .split(',')
1018                    .filter_map(|hdr_value| match hdr_value.trim() {
1019                        "" => std::option::Option::None,
1020                        hdr_value => std::option::Option::Some({
1021                            match <HitDetail as std::str::FromStr>::from_str(hdr_value) {
1022                                std::result::Result::Ok(value) => std::result::Result::Ok(value),
1023                                std::result::Result::Err(err) => std::result::Result::Err(format!(
1024                                    "Unable to convert header value '{}' into HitDetail - {}",
1025                                    hdr_value, err
1026                                )),
1027                            }
1028                        }),
1029                    })
1030                    .collect::<std::result::Result<std::vec::Vec<_>, String>>()?;
1031
1032                std::result::Result::Ok(header::IntoHeaderValue(hdr_values))
1033            }
1034            std::result::Result::Err(e) => std::result::Result::Err(format!(
1035                "Unable to parse header: {:?} as a string - {}",
1036                hdr_values, e
1037            )),
1038        }
1039    }
1040}
1041
1042#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
1043#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
1044pub struct Hitbox {
1045    #[serde(rename = "point")]
1046    #[serde(skip_serializing_if = "Option::is_none")]
1047    pub point: Option<models::Point>,
1048
1049    #[serde(rename = "radius")]
1050    #[serde(skip_serializing_if = "Option::is_none")]
1051    pub radius: Option<i32>,
1052}
1053
1054impl Hitbox {
1055    #[allow(clippy::new_without_default)]
1056    pub fn new() -> Hitbox {
1057        Hitbox {
1058            point: None,
1059            radius: None,
1060        }
1061    }
1062}
1063
1064/// Converts the Hitbox value to the Query Parameters representation (style=form, explode=false)
1065/// specified in https://swagger.io/docs/specification/serialization/
1066/// Should be implemented in a serde serializer
1067impl std::string::ToString for Hitbox {
1068    fn to_string(&self) -> String {
1069        let params: Vec<Option<String>> = vec![
1070            // Skipping non-primitive type point in query parameter serialization
1071            self.radius
1072                .as_ref()
1073                .map(|radius| ["radius".to_string(), radius.to_string()].join(",")),
1074        ];
1075
1076        params.into_iter().flatten().collect::<Vec<_>>().join(",")
1077    }
1078}
1079
1080/// Converts Query Parameters representation (style=form, explode=false) to a Hitbox value
1081/// as specified in https://swagger.io/docs/specification/serialization/
1082/// Should be implemented in a serde deserializer
1083impl std::str::FromStr for Hitbox {
1084    type Err = String;
1085
1086    fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
1087        /// An intermediate representation of the struct to use for parsing.
1088        #[derive(Default)]
1089        #[allow(dead_code)]
1090        struct IntermediateRep {
1091            pub point: Vec<models::Point>,
1092            pub radius: Vec<i32>,
1093        }
1094
1095        let mut intermediate_rep = IntermediateRep::default();
1096
1097        // Parse into intermediate representation
1098        let mut string_iter = s.split(',');
1099        let mut key_result = string_iter.next();
1100
1101        while key_result.is_some() {
1102            let val = match string_iter.next() {
1103                Some(x) => x,
1104                None => {
1105                    return std::result::Result::Err(
1106                        "Missing value while parsing Hitbox".to_string(),
1107                    )
1108                }
1109            };
1110
1111            if let Some(key) = key_result {
1112                #[allow(clippy::match_single_binding)]
1113                match key {
1114                    #[allow(clippy::redundant_clone)]
1115                    "point" => intermediate_rep.point.push(
1116                        <models::Point as std::str::FromStr>::from_str(val)
1117                            .map_err(|x| x.to_string())?,
1118                    ),
1119                    #[allow(clippy::redundant_clone)]
1120                    "radius" => intermediate_rep.radius.push(
1121                        <i32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?,
1122                    ),
1123                    _ => {
1124                        return std::result::Result::Err(
1125                            "Unexpected key while parsing Hitbox".to_string(),
1126                        )
1127                    }
1128                }
1129            }
1130
1131            // Get the next key
1132            key_result = string_iter.next();
1133        }
1134
1135        // Use the intermediate representation to return the struct
1136        std::result::Result::Ok(Hitbox {
1137            point: intermediate_rep.point.into_iter().next(),
1138            radius: intermediate_rep.radius.into_iter().next(),
1139        })
1140    }
1141}
1142
1143// Methods for converting between header::IntoHeaderValue<Hitbox> and hyper::header::HeaderValue
1144
1145#[cfg(any(feature = "client", feature = "server"))]
1146impl std::convert::TryFrom<header::IntoHeaderValue<Hitbox>> for hyper::header::HeaderValue {
1147    type Error = String;
1148
1149    fn try_from(
1150        hdr_value: header::IntoHeaderValue<Hitbox>,
1151    ) -> std::result::Result<Self, Self::Error> {
1152        let hdr_value = hdr_value.to_string();
1153        match hyper::header::HeaderValue::from_str(&hdr_value) {
1154            std::result::Result::Ok(value) => std::result::Result::Ok(value),
1155            std::result::Result::Err(e) => std::result::Result::Err(format!(
1156                "Invalid header value for Hitbox - value: {} is invalid {}",
1157                hdr_value, e
1158            )),
1159        }
1160    }
1161}
1162
1163#[cfg(any(feature = "client", feature = "server"))]
1164impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<Hitbox> {
1165    type Error = String;
1166
1167    fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
1168        match hdr_value.to_str() {
1169            std::result::Result::Ok(value) => {
1170                match <Hitbox as std::str::FromStr>::from_str(value) {
1171                    std::result::Result::Ok(value) => {
1172                        std::result::Result::Ok(header::IntoHeaderValue(value))
1173                    }
1174                    std::result::Result::Err(err) => std::result::Result::Err(format!(
1175                        "Unable to convert header value '{}' into Hitbox - {}",
1176                        value, err
1177                    )),
1178                }
1179            }
1180            std::result::Result::Err(e) => std::result::Result::Err(format!(
1181                "Unable to convert header: {:?} to string: {}",
1182                hdr_value, e
1183            )),
1184        }
1185    }
1186}
1187
1188#[cfg(feature = "server")]
1189impl std::convert::TryFrom<header::IntoHeaderValue<Vec<Hitbox>>> for hyper::header::HeaderValue {
1190    type Error = String;
1191
1192    fn try_from(
1193        hdr_values: header::IntoHeaderValue<Vec<Hitbox>>,
1194    ) -> std::result::Result<Self, Self::Error> {
1195        let hdr_values: Vec<String> = hdr_values
1196            .0
1197            .into_iter()
1198            .map(|hdr_value| hdr_value.to_string())
1199            .collect();
1200
1201        match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) {
1202            std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value),
1203            std::result::Result::Err(e) => std::result::Result::Err(format!(
1204                "Unable to convert {:?} into a header - {}",
1205                hdr_values, e
1206            )),
1207        }
1208    }
1209}
1210
1211#[cfg(feature = "server")]
1212impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<Vec<Hitbox>> {
1213    type Error = String;
1214
1215    fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
1216        match hdr_values.to_str() {
1217            std::result::Result::Ok(hdr_values) => {
1218                let hdr_values: std::vec::Vec<Hitbox> = hdr_values
1219                    .split(',')
1220                    .filter_map(|hdr_value| match hdr_value.trim() {
1221                        "" => std::option::Option::None,
1222                        hdr_value => std::option::Option::Some({
1223                            match <Hitbox as std::str::FromStr>::from_str(hdr_value) {
1224                                std::result::Result::Ok(value) => std::result::Result::Ok(value),
1225                                std::result::Result::Err(err) => std::result::Result::Err(format!(
1226                                    "Unable to convert header value '{}' into Hitbox - {}",
1227                                    hdr_value, err
1228                                )),
1229                            }
1230                        }),
1231                    })
1232                    .collect::<std::result::Result<std::vec::Vec<_>, String>>()?;
1233
1234                std::result::Result::Ok(header::IntoHeaderValue(hdr_values))
1235            }
1236            std::result::Result::Err(e) => std::result::Result::Err(format!(
1237                "Unable to parse header: {:?} as a string - {}",
1238                hdr_values, e
1239            )),
1240        }
1241    }
1242}
1243
1244#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
1245#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
1246pub struct MapDto {
1247    #[serde(rename = "point")]
1248    #[serde(skip_serializing_if = "Option::is_none")]
1249    pub point: Option<models::Hitbox>,
1250
1251    #[serde(rename = "time")]
1252    #[serde(skip_serializing_if = "Option::is_none")]
1253    pub time: Option<i32>,
1254}
1255
1256impl MapDto {
1257    #[allow(clippy::new_without_default)]
1258    pub fn new() -> MapDto {
1259        MapDto {
1260            point: None,
1261            time: None,
1262        }
1263    }
1264}
1265
1266/// Converts the MapDto value to the Query Parameters representation (style=form, explode=false)
1267/// specified in https://swagger.io/docs/specification/serialization/
1268/// Should be implemented in a serde serializer
1269impl std::string::ToString for MapDto {
1270    fn to_string(&self) -> String {
1271        let params: Vec<Option<String>> = vec![
1272            // Skipping non-primitive type point in query parameter serialization
1273            self.time
1274                .as_ref()
1275                .map(|time| ["time".to_string(), time.to_string()].join(",")),
1276        ];
1277
1278        params.into_iter().flatten().collect::<Vec<_>>().join(",")
1279    }
1280}
1281
1282/// Converts Query Parameters representation (style=form, explode=false) to a MapDto value
1283/// as specified in https://swagger.io/docs/specification/serialization/
1284/// Should be implemented in a serde deserializer
1285impl std::str::FromStr for MapDto {
1286    type Err = String;
1287
1288    fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
1289        /// An intermediate representation of the struct to use for parsing.
1290        #[derive(Default)]
1291        #[allow(dead_code)]
1292        struct IntermediateRep {
1293            pub point: Vec<models::Hitbox>,
1294            pub time: Vec<i32>,
1295        }
1296
1297        let mut intermediate_rep = IntermediateRep::default();
1298
1299        // Parse into intermediate representation
1300        let mut string_iter = s.split(',');
1301        let mut key_result = string_iter.next();
1302
1303        while key_result.is_some() {
1304            let val = match string_iter.next() {
1305                Some(x) => x,
1306                None => {
1307                    return std::result::Result::Err(
1308                        "Missing value while parsing MapDto".to_string(),
1309                    )
1310                }
1311            };
1312
1313            if let Some(key) = key_result {
1314                #[allow(clippy::match_single_binding)]
1315                match key {
1316                    #[allow(clippy::redundant_clone)]
1317                    "point" => intermediate_rep.point.push(
1318                        <models::Hitbox as std::str::FromStr>::from_str(val)
1319                            .map_err(|x| x.to_string())?,
1320                    ),
1321                    #[allow(clippy::redundant_clone)]
1322                    "time" => intermediate_rep.time.push(
1323                        <i32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?,
1324                    ),
1325                    _ => {
1326                        return std::result::Result::Err(
1327                            "Unexpected key while parsing MapDto".to_string(),
1328                        )
1329                    }
1330                }
1331            }
1332
1333            // Get the next key
1334            key_result = string_iter.next();
1335        }
1336
1337        // Use the intermediate representation to return the struct
1338        std::result::Result::Ok(MapDto {
1339            point: intermediate_rep.point.into_iter().next(),
1340            time: intermediate_rep.time.into_iter().next(),
1341        })
1342    }
1343}
1344
1345// Methods for converting between header::IntoHeaderValue<MapDto> and hyper::header::HeaderValue
1346
1347#[cfg(any(feature = "client", feature = "server"))]
1348impl std::convert::TryFrom<header::IntoHeaderValue<MapDto>> for hyper::header::HeaderValue {
1349    type Error = String;
1350
1351    fn try_from(
1352        hdr_value: header::IntoHeaderValue<MapDto>,
1353    ) -> std::result::Result<Self, Self::Error> {
1354        let hdr_value = hdr_value.to_string();
1355        match hyper::header::HeaderValue::from_str(&hdr_value) {
1356            std::result::Result::Ok(value) => std::result::Result::Ok(value),
1357            std::result::Result::Err(e) => std::result::Result::Err(format!(
1358                "Invalid header value for MapDto - value: {} is invalid {}",
1359                hdr_value, e
1360            )),
1361        }
1362    }
1363}
1364
1365#[cfg(any(feature = "client", feature = "server"))]
1366impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<MapDto> {
1367    type Error = String;
1368
1369    fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
1370        match hdr_value.to_str() {
1371            std::result::Result::Ok(value) => {
1372                match <MapDto as std::str::FromStr>::from_str(value) {
1373                    std::result::Result::Ok(value) => {
1374                        std::result::Result::Ok(header::IntoHeaderValue(value))
1375                    }
1376                    std::result::Result::Err(err) => std::result::Result::Err(format!(
1377                        "Unable to convert header value '{}' into MapDto - {}",
1378                        value, err
1379                    )),
1380                }
1381            }
1382            std::result::Result::Err(e) => std::result::Result::Err(format!(
1383                "Unable to convert header: {:?} to string: {}",
1384                hdr_value, e
1385            )),
1386        }
1387    }
1388}
1389
1390#[cfg(feature = "server")]
1391impl std::convert::TryFrom<header::IntoHeaderValue<Vec<MapDto>>> for hyper::header::HeaderValue {
1392    type Error = String;
1393
1394    fn try_from(
1395        hdr_values: header::IntoHeaderValue<Vec<MapDto>>,
1396    ) -> std::result::Result<Self, Self::Error> {
1397        let hdr_values: Vec<String> = hdr_values
1398            .0
1399            .into_iter()
1400            .map(|hdr_value| hdr_value.to_string())
1401            .collect();
1402
1403        match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) {
1404            std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value),
1405            std::result::Result::Err(e) => std::result::Result::Err(format!(
1406                "Unable to convert {:?} into a header - {}",
1407                hdr_values, e
1408            )),
1409        }
1410    }
1411}
1412
1413#[cfg(feature = "server")]
1414impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<Vec<MapDto>> {
1415    type Error = String;
1416
1417    fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
1418        match hdr_values.to_str() {
1419            std::result::Result::Ok(hdr_values) => {
1420                let hdr_values: std::vec::Vec<MapDto> = hdr_values
1421                    .split(',')
1422                    .filter_map(|hdr_value| match hdr_value.trim() {
1423                        "" => std::option::Option::None,
1424                        hdr_value => std::option::Option::Some({
1425                            match <MapDto as std::str::FromStr>::from_str(hdr_value) {
1426                                std::result::Result::Ok(value) => std::result::Result::Ok(value),
1427                                std::result::Result::Err(err) => std::result::Result::Err(format!(
1428                                    "Unable to convert header value '{}' into MapDto - {}",
1429                                    hdr_value, err
1430                                )),
1431                            }
1432                        }),
1433                    })
1434                    .collect::<std::result::Result<std::vec::Vec<_>, String>>()?;
1435
1436                std::result::Result::Ok(header::IntoHeaderValue(hdr_values))
1437            }
1438            std::result::Result::Err(e) => std::result::Result::Err(format!(
1439                "Unable to parse header: {:?} as a string - {}",
1440                hdr_values, e
1441            )),
1442        }
1443    }
1444}
1445
1446#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
1447#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
1448pub struct Point {
1449    #[serde(rename = "x")]
1450    #[serde(skip_serializing_if = "Option::is_none")]
1451    pub x: Option<i32>,
1452
1453    #[serde(rename = "y")]
1454    #[serde(skip_serializing_if = "Option::is_none")]
1455    pub y: Option<i32>,
1456}
1457
1458impl Point {
1459    #[allow(clippy::new_without_default)]
1460    pub fn new() -> Point {
1461        Point { x: None, y: None }
1462    }
1463}
1464
1465/// Converts the Point value to the Query Parameters representation (style=form, explode=false)
1466/// specified in https://swagger.io/docs/specification/serialization/
1467/// Should be implemented in a serde serializer
1468impl std::string::ToString for Point {
1469    fn to_string(&self) -> String {
1470        let params: Vec<Option<String>> = vec![
1471            self.x
1472                .as_ref()
1473                .map(|x| ["x".to_string(), x.to_string()].join(",")),
1474            self.y
1475                .as_ref()
1476                .map(|y| ["y".to_string(), y.to_string()].join(",")),
1477        ];
1478
1479        params.into_iter().flatten().collect::<Vec<_>>().join(",")
1480    }
1481}
1482
1483/// Converts Query Parameters representation (style=form, explode=false) to a Point value
1484/// as specified in https://swagger.io/docs/specification/serialization/
1485/// Should be implemented in a serde deserializer
1486impl std::str::FromStr for Point {
1487    type Err = String;
1488
1489    fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
1490        /// An intermediate representation of the struct to use for parsing.
1491        #[derive(Default)]
1492        #[allow(dead_code)]
1493        struct IntermediateRep {
1494            pub x: Vec<i32>,
1495            pub y: Vec<i32>,
1496        }
1497
1498        let mut intermediate_rep = IntermediateRep::default();
1499
1500        // Parse into intermediate representation
1501        let mut string_iter = s.split(',');
1502        let mut key_result = string_iter.next();
1503
1504        while key_result.is_some() {
1505            let val = match string_iter.next() {
1506                Some(x) => x,
1507                None => {
1508                    return std::result::Result::Err(
1509                        "Missing value while parsing Point".to_string(),
1510                    )
1511                }
1512            };
1513
1514            if let Some(key) = key_result {
1515                #[allow(clippy::match_single_binding)]
1516                match key {
1517                    #[allow(clippy::redundant_clone)]
1518                    "x" => intermediate_rep.x.push(
1519                        <i32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?,
1520                    ),
1521                    #[allow(clippy::redundant_clone)]
1522                    "y" => intermediate_rep.y.push(
1523                        <i32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?,
1524                    ),
1525                    _ => {
1526                        return std::result::Result::Err(
1527                            "Unexpected key while parsing Point".to_string(),
1528                        )
1529                    }
1530                }
1531            }
1532
1533            // Get the next key
1534            key_result = string_iter.next();
1535        }
1536
1537        // Use the intermediate representation to return the struct
1538        std::result::Result::Ok(Point {
1539            x: intermediate_rep.x.into_iter().next(),
1540            y: intermediate_rep.y.into_iter().next(),
1541        })
1542    }
1543}
1544
1545// Methods for converting between header::IntoHeaderValue<Point> and hyper::header::HeaderValue
1546
1547#[cfg(any(feature = "client", feature = "server"))]
1548impl std::convert::TryFrom<header::IntoHeaderValue<Point>> for hyper::header::HeaderValue {
1549    type Error = String;
1550
1551    fn try_from(
1552        hdr_value: header::IntoHeaderValue<Point>,
1553    ) -> std::result::Result<Self, Self::Error> {
1554        let hdr_value = hdr_value.to_string();
1555        match hyper::header::HeaderValue::from_str(&hdr_value) {
1556            std::result::Result::Ok(value) => std::result::Result::Ok(value),
1557            std::result::Result::Err(e) => std::result::Result::Err(format!(
1558                "Invalid header value for Point - value: {} is invalid {}",
1559                hdr_value, e
1560            )),
1561        }
1562    }
1563}
1564
1565#[cfg(any(feature = "client", feature = "server"))]
1566impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<Point> {
1567    type Error = String;
1568
1569    fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
1570        match hdr_value.to_str() {
1571            std::result::Result::Ok(value) => match <Point as std::str::FromStr>::from_str(value) {
1572                std::result::Result::Ok(value) => {
1573                    std::result::Result::Ok(header::IntoHeaderValue(value))
1574                }
1575                std::result::Result::Err(err) => std::result::Result::Err(format!(
1576                    "Unable to convert header value '{}' into Point - {}",
1577                    value, err
1578                )),
1579            },
1580            std::result::Result::Err(e) => std::result::Result::Err(format!(
1581                "Unable to convert header: {:?} to string: {}",
1582                hdr_value, e
1583            )),
1584        }
1585    }
1586}
1587
1588#[cfg(feature = "server")]
1589impl std::convert::TryFrom<header::IntoHeaderValue<Vec<Point>>> for hyper::header::HeaderValue {
1590    type Error = String;
1591
1592    fn try_from(
1593        hdr_values: header::IntoHeaderValue<Vec<Point>>,
1594    ) -> std::result::Result<Self, Self::Error> {
1595        let hdr_values: Vec<String> = hdr_values
1596            .0
1597            .into_iter()
1598            .map(|hdr_value| hdr_value.to_string())
1599            .collect();
1600
1601        match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) {
1602            std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value),
1603            std::result::Result::Err(e) => std::result::Result::Err(format!(
1604                "Unable to convert {:?} into a header - {}",
1605                hdr_values, e
1606            )),
1607        }
1608    }
1609}
1610
1611#[cfg(feature = "server")]
1612impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<Vec<Point>> {
1613    type Error = String;
1614
1615    fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
1616        match hdr_values.to_str() {
1617            std::result::Result::Ok(hdr_values) => {
1618                let hdr_values: std::vec::Vec<Point> = hdr_values
1619                    .split(',')
1620                    .filter_map(|hdr_value| match hdr_value.trim() {
1621                        "" => std::option::Option::None,
1622                        hdr_value => std::option::Option::Some({
1623                            match <Point as std::str::FromStr>::from_str(hdr_value) {
1624                                std::result::Result::Ok(value) => std::result::Result::Ok(value),
1625                                std::result::Result::Err(err) => std::result::Result::Err(format!(
1626                                    "Unable to convert header value '{}' into Point - {}",
1627                                    hdr_value, err
1628                                )),
1629                            }
1630                        }),
1631                    })
1632                    .collect::<std::result::Result<std::vec::Vec<_>, String>>()?;
1633
1634                std::result::Result::Ok(header::IntoHeaderValue(hdr_values))
1635            }
1636            std::result::Result::Err(e) => std::result::Result::Err(format!(
1637                "Unable to parse header: {:?} as a string - {}",
1638                hdr_values, e
1639            )),
1640        }
1641    }
1642}
1643
1644#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
1645#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
1646pub struct ResultDto {
1647    #[serde(rename = "score")]
1648    #[serde(skip_serializing_if = "Option::is_none")]
1649    pub score: Option<i64>,
1650
1651    #[serde(rename = "accuracy")]
1652    #[serde(skip_serializing_if = "Option::is_none")]
1653    pub accuracy: Option<f32>,
1654
1655    #[serde(rename = "Details")]
1656    #[serde(skip_serializing_if = "Option::is_none")]
1657    pub details: Option<models::HitDetail>,
1658
1659    #[serde(rename = "averageOffsetTime")]
1660    #[serde(skip_serializing_if = "Option::is_none")]
1661    pub average_offset_time: Option<i32>,
1662
1663    #[serde(rename = "Elo")]
1664    #[serde(skip_serializing_if = "Option::is_none")]
1665    pub elo: Option<models::Tier>,
1666
1667    #[serde(rename = "pb")]
1668    #[serde(skip_serializing_if = "Option::is_none")]
1669    pub pb: Option<bool>,
1670
1671    #[serde(rename = "user")]
1672    #[serde(skip_serializing_if = "Option::is_none")]
1673    pub user: Option<String>,
1674}
1675
1676impl ResultDto {
1677    #[allow(clippy::new_without_default)]
1678    pub fn new() -> ResultDto {
1679        ResultDto {
1680            score: None,
1681            accuracy: None,
1682            details: None,
1683            average_offset_time: None,
1684            elo: None,
1685            pb: None,
1686            user: None,
1687        }
1688    }
1689}
1690
1691/// Converts the ResultDto value to the Query Parameters representation (style=form, explode=false)
1692/// specified in https://swagger.io/docs/specification/serialization/
1693/// Should be implemented in a serde serializer
1694impl std::string::ToString for ResultDto {
1695    fn to_string(&self) -> String {
1696        let params: Vec<Option<String>> = vec![
1697            self.score
1698                .as_ref()
1699                .map(|score| ["score".to_string(), score.to_string()].join(",")),
1700            self.accuracy
1701                .as_ref()
1702                .map(|accuracy| ["accuracy".to_string(), accuracy.to_string()].join(",")),
1703            // Skipping non-primitive type Details in query parameter serialization
1704            self.average_offset_time
1705                .as_ref()
1706                .map(|average_offset_time| {
1707                    [
1708                        "averageOffsetTime".to_string(),
1709                        average_offset_time.to_string(),
1710                    ]
1711                    .join(",")
1712                }),
1713            // Skipping non-primitive type Elo in query parameter serialization
1714            self.pb
1715                .as_ref()
1716                .map(|pb| ["pb".to_string(), pb.to_string()].join(",")),
1717            self.user
1718                .as_ref()
1719                .map(|user| ["user".to_string(), user.to_string()].join(",")),
1720        ];
1721
1722        params.into_iter().flatten().collect::<Vec<_>>().join(",")
1723    }
1724}
1725
1726/// Converts Query Parameters representation (style=form, explode=false) to a ResultDto value
1727/// as specified in https://swagger.io/docs/specification/serialization/
1728/// Should be implemented in a serde deserializer
1729impl std::str::FromStr for ResultDto {
1730    type Err = String;
1731
1732    fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
1733        /// An intermediate representation of the struct to use for parsing.
1734        #[derive(Default)]
1735        #[allow(dead_code)]
1736        struct IntermediateRep {
1737            pub score: Vec<i64>,
1738            pub accuracy: Vec<f32>,
1739            pub details: Vec<models::HitDetail>,
1740            pub average_offset_time: Vec<i32>,
1741            pub elo: Vec<models::Tier>,
1742            pub pb: Vec<bool>,
1743            pub user: Vec<String>,
1744        }
1745
1746        let mut intermediate_rep = IntermediateRep::default();
1747
1748        // Parse into intermediate representation
1749        let mut string_iter = s.split(',');
1750        let mut key_result = string_iter.next();
1751
1752        while key_result.is_some() {
1753            let val = match string_iter.next() {
1754                Some(x) => x,
1755                None => {
1756                    return std::result::Result::Err(
1757                        "Missing value while parsing ResultDto".to_string(),
1758                    )
1759                }
1760            };
1761
1762            if let Some(key) = key_result {
1763                #[allow(clippy::match_single_binding)]
1764                match key {
1765                    #[allow(clippy::redundant_clone)]
1766                    "score" => intermediate_rep.score.push(
1767                        <i64 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?,
1768                    ),
1769                    #[allow(clippy::redundant_clone)]
1770                    "accuracy" => intermediate_rep.accuracy.push(
1771                        <f32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?,
1772                    ),
1773                    #[allow(clippy::redundant_clone)]
1774                    "Details" => intermediate_rep.details.push(
1775                        <models::HitDetail as std::str::FromStr>::from_str(val)
1776                            .map_err(|x| x.to_string())?,
1777                    ),
1778                    #[allow(clippy::redundant_clone)]
1779                    "averageOffsetTime" => intermediate_rep.average_offset_time.push(
1780                        <i32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?,
1781                    ),
1782                    #[allow(clippy::redundant_clone)]
1783                    "Elo" => intermediate_rep.elo.push(
1784                        <models::Tier as std::str::FromStr>::from_str(val)
1785                            .map_err(|x| x.to_string())?,
1786                    ),
1787                    #[allow(clippy::redundant_clone)]
1788                    "pb" => intermediate_rep.pb.push(
1789                        <bool as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?,
1790                    ),
1791                    #[allow(clippy::redundant_clone)]
1792                    "user" => intermediate_rep.user.push(
1793                        <String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?,
1794                    ),
1795                    _ => {
1796                        return std::result::Result::Err(
1797                            "Unexpected key while parsing ResultDto".to_string(),
1798                        )
1799                    }
1800                }
1801            }
1802
1803            // Get the next key
1804            key_result = string_iter.next();
1805        }
1806
1807        // Use the intermediate representation to return the struct
1808        std::result::Result::Ok(ResultDto {
1809            score: intermediate_rep.score.into_iter().next(),
1810            accuracy: intermediate_rep.accuracy.into_iter().next(),
1811            details: intermediate_rep.details.into_iter().next(),
1812            average_offset_time: intermediate_rep.average_offset_time.into_iter().next(),
1813            elo: intermediate_rep.elo.into_iter().next(),
1814            pb: intermediate_rep.pb.into_iter().next(),
1815            user: intermediate_rep.user.into_iter().next(),
1816        })
1817    }
1818}
1819
1820// Methods for converting between header::IntoHeaderValue<ResultDto> and hyper::header::HeaderValue
1821
1822#[cfg(any(feature = "client", feature = "server"))]
1823impl std::convert::TryFrom<header::IntoHeaderValue<ResultDto>> for hyper::header::HeaderValue {
1824    type Error = String;
1825
1826    fn try_from(
1827        hdr_value: header::IntoHeaderValue<ResultDto>,
1828    ) -> std::result::Result<Self, Self::Error> {
1829        let hdr_value = hdr_value.to_string();
1830        match hyper::header::HeaderValue::from_str(&hdr_value) {
1831            std::result::Result::Ok(value) => std::result::Result::Ok(value),
1832            std::result::Result::Err(e) => std::result::Result::Err(format!(
1833                "Invalid header value for ResultDto - value: {} is invalid {}",
1834                hdr_value, e
1835            )),
1836        }
1837    }
1838}
1839
1840#[cfg(any(feature = "client", feature = "server"))]
1841impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<ResultDto> {
1842    type Error = String;
1843
1844    fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
1845        match hdr_value.to_str() {
1846            std::result::Result::Ok(value) => {
1847                match <ResultDto as std::str::FromStr>::from_str(value) {
1848                    std::result::Result::Ok(value) => {
1849                        std::result::Result::Ok(header::IntoHeaderValue(value))
1850                    }
1851                    std::result::Result::Err(err) => std::result::Result::Err(format!(
1852                        "Unable to convert header value '{}' into ResultDto - {}",
1853                        value, err
1854                    )),
1855                }
1856            }
1857            std::result::Result::Err(e) => std::result::Result::Err(format!(
1858                "Unable to convert header: {:?} to string: {}",
1859                hdr_value, e
1860            )),
1861        }
1862    }
1863}
1864
1865#[cfg(feature = "server")]
1866impl std::convert::TryFrom<header::IntoHeaderValue<Vec<ResultDto>>> for hyper::header::HeaderValue {
1867    type Error = String;
1868
1869    fn try_from(
1870        hdr_values: header::IntoHeaderValue<Vec<ResultDto>>,
1871    ) -> std::result::Result<Self, Self::Error> {
1872        let hdr_values: Vec<String> = hdr_values
1873            .0
1874            .into_iter()
1875            .map(|hdr_value| hdr_value.to_string())
1876            .collect();
1877
1878        match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) {
1879            std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value),
1880            std::result::Result::Err(e) => std::result::Result::Err(format!(
1881                "Unable to convert {:?} into a header - {}",
1882                hdr_values, e
1883            )),
1884        }
1885    }
1886}
1887
1888#[cfg(feature = "server")]
1889impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<Vec<ResultDto>> {
1890    type Error = String;
1891
1892    fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
1893        match hdr_values.to_str() {
1894            std::result::Result::Ok(hdr_values) => {
1895                let hdr_values: std::vec::Vec<ResultDto> = hdr_values
1896                    .split(',')
1897                    .filter_map(|hdr_value| match hdr_value.trim() {
1898                        "" => std::option::Option::None,
1899                        hdr_value => std::option::Option::Some({
1900                            match <ResultDto as std::str::FromStr>::from_str(hdr_value) {
1901                                std::result::Result::Ok(value) => std::result::Result::Ok(value),
1902                                std::result::Result::Err(err) => std::result::Result::Err(format!(
1903                                    "Unable to convert header value '{}' into ResultDto - {}",
1904                                    hdr_value, err
1905                                )),
1906                            }
1907                        }),
1908                    })
1909                    .collect::<std::result::Result<std::vec::Vec<_>, String>>()?;
1910
1911                std::result::Result::Ok(header::IntoHeaderValue(hdr_values))
1912            }
1913            std::result::Result::Err(e) => std::result::Result::Err(format!(
1914                "Unable to parse header: {:?} as a string - {}",
1915                hdr_values, e
1916            )),
1917        }
1918    }
1919}
1920
1921#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
1922#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
1923pub struct Spawn {
1924    #[serde(rename = "hitbox")]
1925    #[serde(skip_serializing_if = "Option::is_none")]
1926    pub hitbox: Option<models::Hitbox>,
1927
1928    #[serde(rename = "time")]
1929    #[serde(skip_serializing_if = "Option::is_none")]
1930    pub time: Option<i32>,
1931}
1932
1933impl Spawn {
1934    #[allow(clippy::new_without_default)]
1935    pub fn new() -> Spawn {
1936        Spawn {
1937            hitbox: None,
1938            time: None,
1939        }
1940    }
1941}
1942
1943/// Converts the Spawn value to the Query Parameters representation (style=form, explode=false)
1944/// specified in https://swagger.io/docs/specification/serialization/
1945/// Should be implemented in a serde serializer
1946impl std::string::ToString for Spawn {
1947    fn to_string(&self) -> String {
1948        let params: Vec<Option<String>> = vec![
1949            // Skipping non-primitive type hitbox in query parameter serialization
1950            self.time
1951                .as_ref()
1952                .map(|time| ["time".to_string(), time.to_string()].join(",")),
1953        ];
1954
1955        params.into_iter().flatten().collect::<Vec<_>>().join(",")
1956    }
1957}
1958
1959/// Converts Query Parameters representation (style=form, explode=false) to a Spawn value
1960/// as specified in https://swagger.io/docs/specification/serialization/
1961/// Should be implemented in a serde deserializer
1962impl std::str::FromStr for Spawn {
1963    type Err = String;
1964
1965    fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
1966        /// An intermediate representation of the struct to use for parsing.
1967        #[derive(Default)]
1968        #[allow(dead_code)]
1969        struct IntermediateRep {
1970            pub hitbox: Vec<models::Hitbox>,
1971            pub time: Vec<i32>,
1972        }
1973
1974        let mut intermediate_rep = IntermediateRep::default();
1975
1976        // Parse into intermediate representation
1977        let mut string_iter = s.split(',');
1978        let mut key_result = string_iter.next();
1979
1980        while key_result.is_some() {
1981            let val = match string_iter.next() {
1982                Some(x) => x,
1983                None => {
1984                    return std::result::Result::Err(
1985                        "Missing value while parsing Spawn".to_string(),
1986                    )
1987                }
1988            };
1989
1990            if let Some(key) = key_result {
1991                #[allow(clippy::match_single_binding)]
1992                match key {
1993                    #[allow(clippy::redundant_clone)]
1994                    "hitbox" => intermediate_rep.hitbox.push(
1995                        <models::Hitbox as std::str::FromStr>::from_str(val)
1996                            .map_err(|x| x.to_string())?,
1997                    ),
1998                    #[allow(clippy::redundant_clone)]
1999                    "time" => intermediate_rep.time.push(
2000                        <i32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?,
2001                    ),
2002                    _ => {
2003                        return std::result::Result::Err(
2004                            "Unexpected key while parsing Spawn".to_string(),
2005                        )
2006                    }
2007                }
2008            }
2009
2010            // Get the next key
2011            key_result = string_iter.next();
2012        }
2013
2014        // Use the intermediate representation to return the struct
2015        std::result::Result::Ok(Spawn {
2016            hitbox: intermediate_rep.hitbox.into_iter().next(),
2017            time: intermediate_rep.time.into_iter().next(),
2018        })
2019    }
2020}
2021
2022// Methods for converting between header::IntoHeaderValue<Spawn> and hyper::header::HeaderValue
2023
2024#[cfg(any(feature = "client", feature = "server"))]
2025impl std::convert::TryFrom<header::IntoHeaderValue<Spawn>> for hyper::header::HeaderValue {
2026    type Error = String;
2027
2028    fn try_from(
2029        hdr_value: header::IntoHeaderValue<Spawn>,
2030    ) -> std::result::Result<Self, Self::Error> {
2031        let hdr_value = hdr_value.to_string();
2032        match hyper::header::HeaderValue::from_str(&hdr_value) {
2033            std::result::Result::Ok(value) => std::result::Result::Ok(value),
2034            std::result::Result::Err(e) => std::result::Result::Err(format!(
2035                "Invalid header value for Spawn - value: {} is invalid {}",
2036                hdr_value, e
2037            )),
2038        }
2039    }
2040}
2041
2042#[cfg(any(feature = "client", feature = "server"))]
2043impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<Spawn> {
2044    type Error = String;
2045
2046    fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
2047        match hdr_value.to_str() {
2048            std::result::Result::Ok(value) => match <Spawn as std::str::FromStr>::from_str(value) {
2049                std::result::Result::Ok(value) => {
2050                    std::result::Result::Ok(header::IntoHeaderValue(value))
2051                }
2052                std::result::Result::Err(err) => std::result::Result::Err(format!(
2053                    "Unable to convert header value '{}' into Spawn - {}",
2054                    value, err
2055                )),
2056            },
2057            std::result::Result::Err(e) => std::result::Result::Err(format!(
2058                "Unable to convert header: {:?} to string: {}",
2059                hdr_value, e
2060            )),
2061        }
2062    }
2063}
2064
2065#[cfg(feature = "server")]
2066impl std::convert::TryFrom<header::IntoHeaderValue<Vec<Spawn>>> for hyper::header::HeaderValue {
2067    type Error = String;
2068
2069    fn try_from(
2070        hdr_values: header::IntoHeaderValue<Vec<Spawn>>,
2071    ) -> std::result::Result<Self, Self::Error> {
2072        let hdr_values: Vec<String> = hdr_values
2073            .0
2074            .into_iter()
2075            .map(|hdr_value| hdr_value.to_string())
2076            .collect();
2077
2078        match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) {
2079            std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value),
2080            std::result::Result::Err(e) => std::result::Result::Err(format!(
2081                "Unable to convert {:?} into a header - {}",
2082                hdr_values, e
2083            )),
2084        }
2085    }
2086}
2087
2088#[cfg(feature = "server")]
2089impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<Vec<Spawn>> {
2090    type Error = String;
2091
2092    fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
2093        match hdr_values.to_str() {
2094            std::result::Result::Ok(hdr_values) => {
2095                let hdr_values: std::vec::Vec<Spawn> = hdr_values
2096                    .split(',')
2097                    .filter_map(|hdr_value| match hdr_value.trim() {
2098                        "" => std::option::Option::None,
2099                        hdr_value => std::option::Option::Some({
2100                            match <Spawn as std::str::FromStr>::from_str(hdr_value) {
2101                                std::result::Result::Ok(value) => std::result::Result::Ok(value),
2102                                std::result::Result::Err(err) => std::result::Result::Err(format!(
2103                                    "Unable to convert header value '{}' into Spawn - {}",
2104                                    hdr_value, err
2105                                )),
2106                            }
2107                        }),
2108                    })
2109                    .collect::<std::result::Result<std::vec::Vec<_>, String>>()?;
2110
2111                std::result::Result::Ok(header::IntoHeaderValue(hdr_values))
2112            }
2113            std::result::Result::Err(e) => std::result::Result::Err(format!(
2114                "Unable to parse header: {:?} as a string - {}",
2115                hdr_values, e
2116            )),
2117        }
2118    }
2119}
2120
2121#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
2122#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
2123pub struct Tier {
2124    #[serde(rename = "rank")]
2125    #[serde(skip_serializing_if = "Option::is_none")]
2126    pub rank: Option<i32>,
2127
2128    #[serde(rename = "percent")]
2129    #[serde(skip_serializing_if = "Option::is_none")]
2130    pub percent: Option<f32>,
2131}
2132
2133impl Tier {
2134    #[allow(clippy::new_without_default)]
2135    pub fn new() -> Tier {
2136        Tier {
2137            rank: None,
2138            percent: None,
2139        }
2140    }
2141}
2142
2143/// Converts the Tier value to the Query Parameters representation (style=form, explode=false)
2144/// specified in https://swagger.io/docs/specification/serialization/
2145/// Should be implemented in a serde serializer
2146impl std::string::ToString for Tier {
2147    fn to_string(&self) -> String {
2148        let params: Vec<Option<String>> = vec![
2149            self.rank
2150                .as_ref()
2151                .map(|rank| ["rank".to_string(), rank.to_string()].join(",")),
2152            self.percent
2153                .as_ref()
2154                .map(|percent| ["percent".to_string(), percent.to_string()].join(",")),
2155        ];
2156
2157        params.into_iter().flatten().collect::<Vec<_>>().join(",")
2158    }
2159}
2160
2161/// Converts Query Parameters representation (style=form, explode=false) to a Tier value
2162/// as specified in https://swagger.io/docs/specification/serialization/
2163/// Should be implemented in a serde deserializer
2164impl std::str::FromStr for Tier {
2165    type Err = String;
2166
2167    fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
2168        /// An intermediate representation of the struct to use for parsing.
2169        #[derive(Default)]
2170        #[allow(dead_code)]
2171        struct IntermediateRep {
2172            pub rank: Vec<i32>,
2173            pub percent: Vec<f32>,
2174        }
2175
2176        let mut intermediate_rep = IntermediateRep::default();
2177
2178        // Parse into intermediate representation
2179        let mut string_iter = s.split(',');
2180        let mut key_result = string_iter.next();
2181
2182        while key_result.is_some() {
2183            let val = match string_iter.next() {
2184                Some(x) => x,
2185                None => {
2186                    return std::result::Result::Err("Missing value while parsing Tier".to_string())
2187                }
2188            };
2189
2190            if let Some(key) = key_result {
2191                #[allow(clippy::match_single_binding)]
2192                match key {
2193                    #[allow(clippy::redundant_clone)]
2194                    "rank" => intermediate_rep.rank.push(
2195                        <i32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?,
2196                    ),
2197                    #[allow(clippy::redundant_clone)]
2198                    "percent" => intermediate_rep.percent.push(
2199                        <f32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?,
2200                    ),
2201                    _ => {
2202                        return std::result::Result::Err(
2203                            "Unexpected key while parsing Tier".to_string(),
2204                        )
2205                    }
2206                }
2207            }
2208
2209            // Get the next key
2210            key_result = string_iter.next();
2211        }
2212
2213        // Use the intermediate representation to return the struct
2214        std::result::Result::Ok(Tier {
2215            rank: intermediate_rep.rank.into_iter().next(),
2216            percent: intermediate_rep.percent.into_iter().next(),
2217        })
2218    }
2219}
2220
2221// Methods for converting between header::IntoHeaderValue<Tier> and hyper::header::HeaderValue
2222
2223#[cfg(any(feature = "client", feature = "server"))]
2224impl std::convert::TryFrom<header::IntoHeaderValue<Tier>> for hyper::header::HeaderValue {
2225    type Error = String;
2226
2227    fn try_from(
2228        hdr_value: header::IntoHeaderValue<Tier>,
2229    ) -> std::result::Result<Self, Self::Error> {
2230        let hdr_value = hdr_value.to_string();
2231        match hyper::header::HeaderValue::from_str(&hdr_value) {
2232            std::result::Result::Ok(value) => std::result::Result::Ok(value),
2233            std::result::Result::Err(e) => std::result::Result::Err(format!(
2234                "Invalid header value for Tier - value: {} is invalid {}",
2235                hdr_value, e
2236            )),
2237        }
2238    }
2239}
2240
2241#[cfg(any(feature = "client", feature = "server"))]
2242impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<Tier> {
2243    type Error = String;
2244
2245    fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
2246        match hdr_value.to_str() {
2247            std::result::Result::Ok(value) => match <Tier as std::str::FromStr>::from_str(value) {
2248                std::result::Result::Ok(value) => {
2249                    std::result::Result::Ok(header::IntoHeaderValue(value))
2250                }
2251                std::result::Result::Err(err) => std::result::Result::Err(format!(
2252                    "Unable to convert header value '{}' into Tier - {}",
2253                    value, err
2254                )),
2255            },
2256            std::result::Result::Err(e) => std::result::Result::Err(format!(
2257                "Unable to convert header: {:?} to string: {}",
2258                hdr_value, e
2259            )),
2260        }
2261    }
2262}
2263
2264#[cfg(feature = "server")]
2265impl std::convert::TryFrom<header::IntoHeaderValue<Vec<Tier>>> for hyper::header::HeaderValue {
2266    type Error = String;
2267
2268    fn try_from(
2269        hdr_values: header::IntoHeaderValue<Vec<Tier>>,
2270    ) -> std::result::Result<Self, Self::Error> {
2271        let hdr_values: Vec<String> = hdr_values
2272            .0
2273            .into_iter()
2274            .map(|hdr_value| hdr_value.to_string())
2275            .collect();
2276
2277        match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) {
2278            std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value),
2279            std::result::Result::Err(e) => std::result::Result::Err(format!(
2280                "Unable to convert {:?} into a header - {}",
2281                hdr_values, e
2282            )),
2283        }
2284    }
2285}
2286
2287#[cfg(feature = "server")]
2288impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<Vec<Tier>> {
2289    type Error = String;
2290
2291    fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
2292        match hdr_values.to_str() {
2293            std::result::Result::Ok(hdr_values) => {
2294                let hdr_values: std::vec::Vec<Tier> = hdr_values
2295                    .split(',')
2296                    .filter_map(|hdr_value| match hdr_value.trim() {
2297                        "" => std::option::Option::None,
2298                        hdr_value => std::option::Option::Some({
2299                            match <Tier as std::str::FromStr>::from_str(hdr_value) {
2300                                std::result::Result::Ok(value) => std::result::Result::Ok(value),
2301                                std::result::Result::Err(err) => std::result::Result::Err(format!(
2302                                    "Unable to convert header value '{}' into Tier - {}",
2303                                    hdr_value, err
2304                                )),
2305                            }
2306                        }),
2307                    })
2308                    .collect::<std::result::Result<std::vec::Vec<_>, String>>()?;
2309
2310                std::result::Result::Ok(header::IntoHeaderValue(hdr_values))
2311            }
2312            std::result::Result::Err(e) => std::result::Result::Err(format!(
2313                "Unable to parse header: {:?} as a string - {}",
2314                hdr_values, e
2315            )),
2316        }
2317    }
2318}
2319
2320#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
2321#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
2322pub struct UserDto {
2323    #[serde(rename = "userName")]
2324    #[serde(skip_serializing_if = "Option::is_none")]
2325    pub user_name: Option<String>,
2326
2327    #[serde(rename = "profilePicture")]
2328    #[serde(skip_serializing_if = "Option::is_none")]
2329    pub profile_picture: Option<String>,
2330}
2331
2332impl UserDto {
2333    #[allow(clippy::new_without_default)]
2334    pub fn new() -> UserDto {
2335        UserDto {
2336            user_name: None,
2337            profile_picture: None,
2338        }
2339    }
2340}
2341
2342/// Converts the UserDto value to the Query Parameters representation (style=form, explode=false)
2343/// specified in https://swagger.io/docs/specification/serialization/
2344/// Should be implemented in a serde serializer
2345impl std::string::ToString for UserDto {
2346    fn to_string(&self) -> String {
2347        let params: Vec<Option<String>> = vec![
2348            self.user_name
2349                .as_ref()
2350                .map(|user_name| ["userName".to_string(), user_name.to_string()].join(",")),
2351            self.profile_picture.as_ref().map(|profile_picture| {
2352                ["profilePicture".to_string(), profile_picture.to_string()].join(",")
2353            }),
2354        ];
2355
2356        params.into_iter().flatten().collect::<Vec<_>>().join(",")
2357    }
2358}
2359
2360/// Converts Query Parameters representation (style=form, explode=false) to a UserDto value
2361/// as specified in https://swagger.io/docs/specification/serialization/
2362/// Should be implemented in a serde deserializer
2363impl std::str::FromStr for UserDto {
2364    type Err = String;
2365
2366    fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
2367        /// An intermediate representation of the struct to use for parsing.
2368        #[derive(Default)]
2369        #[allow(dead_code)]
2370        struct IntermediateRep {
2371            pub user_name: Vec<String>,
2372            pub profile_picture: Vec<String>,
2373        }
2374
2375        let mut intermediate_rep = IntermediateRep::default();
2376
2377        // Parse into intermediate representation
2378        let mut string_iter = s.split(',');
2379        let mut key_result = string_iter.next();
2380
2381        while key_result.is_some() {
2382            let val = match string_iter.next() {
2383                Some(x) => x,
2384                None => {
2385                    return std::result::Result::Err(
2386                        "Missing value while parsing UserDto".to_string(),
2387                    )
2388                }
2389            };
2390
2391            if let Some(key) = key_result {
2392                #[allow(clippy::match_single_binding)]
2393                match key {
2394                    #[allow(clippy::redundant_clone)]
2395                    "userName" => intermediate_rep.user_name.push(
2396                        <String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?,
2397                    ),
2398                    #[allow(clippy::redundant_clone)]
2399                    "profilePicture" => intermediate_rep.profile_picture.push(
2400                        <String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?,
2401                    ),
2402                    _ => {
2403                        return std::result::Result::Err(
2404                            "Unexpected key while parsing UserDto".to_string(),
2405                        )
2406                    }
2407                }
2408            }
2409
2410            // Get the next key
2411            key_result = string_iter.next();
2412        }
2413
2414        // Use the intermediate representation to return the struct
2415        std::result::Result::Ok(UserDto {
2416            user_name: intermediate_rep.user_name.into_iter().next(),
2417            profile_picture: intermediate_rep.profile_picture.into_iter().next(),
2418        })
2419    }
2420}
2421
2422// Methods for converting between header::IntoHeaderValue<UserDto> and hyper::header::HeaderValue
2423
2424#[cfg(any(feature = "client", feature = "server"))]
2425impl std::convert::TryFrom<header::IntoHeaderValue<UserDto>> for hyper::header::HeaderValue {
2426    type Error = String;
2427
2428    fn try_from(
2429        hdr_value: header::IntoHeaderValue<UserDto>,
2430    ) -> std::result::Result<Self, Self::Error> {
2431        let hdr_value = hdr_value.to_string();
2432        match hyper::header::HeaderValue::from_str(&hdr_value) {
2433            std::result::Result::Ok(value) => std::result::Result::Ok(value),
2434            std::result::Result::Err(e) => std::result::Result::Err(format!(
2435                "Invalid header value for UserDto - value: {} is invalid {}",
2436                hdr_value, e
2437            )),
2438        }
2439    }
2440}
2441
2442#[cfg(any(feature = "client", feature = "server"))]
2443impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<UserDto> {
2444    type Error = String;
2445
2446    fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
2447        match hdr_value.to_str() {
2448            std::result::Result::Ok(value) => {
2449                match <UserDto as std::str::FromStr>::from_str(value) {
2450                    std::result::Result::Ok(value) => {
2451                        std::result::Result::Ok(header::IntoHeaderValue(value))
2452                    }
2453                    std::result::Result::Err(err) => std::result::Result::Err(format!(
2454                        "Unable to convert header value '{}' into UserDto - {}",
2455                        value, err
2456                    )),
2457                }
2458            }
2459            std::result::Result::Err(e) => std::result::Result::Err(format!(
2460                "Unable to convert header: {:?} to string: {}",
2461                hdr_value, e
2462            )),
2463        }
2464    }
2465}
2466
2467#[cfg(feature = "server")]
2468impl std::convert::TryFrom<header::IntoHeaderValue<Vec<UserDto>>> for hyper::header::HeaderValue {
2469    type Error = String;
2470
2471    fn try_from(
2472        hdr_values: header::IntoHeaderValue<Vec<UserDto>>,
2473    ) -> std::result::Result<Self, Self::Error> {
2474        let hdr_values: Vec<String> = hdr_values
2475            .0
2476            .into_iter()
2477            .map(|hdr_value| hdr_value.to_string())
2478            .collect();
2479
2480        match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) {
2481            std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value),
2482            std::result::Result::Err(e) => std::result::Result::Err(format!(
2483                "Unable to convert {:?} into a header - {}",
2484                hdr_values, e
2485            )),
2486        }
2487    }
2488}
2489
2490#[cfg(feature = "server")]
2491impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<Vec<UserDto>> {
2492    type Error = String;
2493
2494    fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
2495        match hdr_values.to_str() {
2496            std::result::Result::Ok(hdr_values) => {
2497                let hdr_values: std::vec::Vec<UserDto> = hdr_values
2498                    .split(',')
2499                    .filter_map(|hdr_value| match hdr_value.trim() {
2500                        "" => std::option::Option::None,
2501                        hdr_value => std::option::Option::Some({
2502                            match <UserDto as std::str::FromStr>::from_str(hdr_value) {
2503                                std::result::Result::Ok(value) => std::result::Result::Ok(value),
2504                                std::result::Result::Err(err) => std::result::Result::Err(format!(
2505                                    "Unable to convert header value '{}' into UserDto - {}",
2506                                    hdr_value, err
2507                                )),
2508                            }
2509                        }),
2510                    })
2511                    .collect::<std::result::Result<std::vec::Vec<_>, String>>()?;
2512
2513                std::result::Result::Ok(header::IntoHeaderValue(hdr_values))
2514            }
2515            std::result::Result::Err(e) => std::result::Result::Err(format!(
2516                "Unable to parse header: {:?} as a string - {}",
2517                hdr_values, e
2518            )),
2519        }
2520    }
2521}