1use serde::{Deserialize, Serialize};
11use std::fmt;
12use std::str::FromStr;
13
14#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
16pub enum VehicleCategory {
17 #[serde(rename = "car")]
18 Car,
19 #[serde(rename = "van")]
20 Van,
21 #[serde(rename = "truck")]
22 Truck,
23 #[serde(rename = "semitrailer")]
24 Semitrailer,
25 #[serde(rename = "bus")]
26 Bus,
27 #[serde(rename = "motorbike")]
28 Motorbike,
29 #[serde(rename = "bicycle")]
30 Bicycle,
31 #[serde(rename = "train")]
32 Train,
33 #[serde(rename = "tram")]
34 Tram,
35}
36
37#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
39pub enum PedestrianCategory {
40 #[serde(rename = "pedestrian")]
41 Pedestrian,
42 #[serde(rename = "wheelchair")]
43 Wheelchair,
44 #[serde(rename = "animal")]
45 Animal,
46}
47
48#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
50pub enum ObjectType {
51 #[serde(rename = "vehicle")]
52 Vehicle,
53 #[serde(rename = "pedestrian")]
54 Pedestrian,
55 #[serde(rename = "miscellaneousObject")]
56 MiscellaneousObject,
57}
58
59#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
61pub enum Rule {
62 #[serde(rename = "equalTo")]
63 EqualTo,
64 #[serde(rename = "greaterThan")]
65 GreaterThan,
66 #[serde(rename = "lessThan")]
67 LessThan,
68 #[serde(rename = "greaterOrEqual")]
69 GreaterOrEqual,
70 #[serde(rename = "lessOrEqual")]
71 LessOrEqual,
72 #[serde(rename = "notEqualTo")]
73 NotEqualTo,
74}
75
76#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
78pub enum ConditionEdge {
79 #[serde(rename = "none")]
80 None,
81 #[serde(rename = "rising")]
82 Rising,
83 #[serde(rename = "falling")]
84 Falling,
85 #[serde(rename = "risingOrFalling")]
86 RisingOrFalling,
87}
88
89#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
91pub enum TriggeringEntitiesRule {
92 #[serde(rename = "all")]
93 All,
94 #[serde(rename = "any")]
95 Any,
96}
97
98#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
100pub enum Priority {
101 #[serde(rename = "overwrite")]
102 Overwrite,
103 #[serde(rename = "override")]
104 Override,
105 #[serde(rename = "parallel")]
106 Parallel,
107 #[serde(rename = "skip")]
108 Skip,
109}
110
111#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
113pub enum StoryboardElementState {
114 #[serde(rename = "completeState")]
115 CompleteState,
116 #[serde(rename = "endTransition")]
117 EndTransition,
118 #[serde(rename = "runningState")]
119 RunningState,
120 #[serde(rename = "skipTransition")]
121 SkipTransition,
122 #[serde(rename = "standbyState")]
123 StandbyState,
124 #[serde(rename = "startTransition")]
125 StartTransition,
126 #[serde(rename = "stopTransition")]
127 StopTransition,
128}
129
130#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
132pub enum StoryboardElementType {
133 #[serde(rename = "act")]
134 Act,
135 #[serde(rename = "action")]
136 Action,
137 #[serde(rename = "event")]
138 Event,
139 #[serde(rename = "maneuver")]
140 Maneuver,
141 #[serde(rename = "maneuverGroup")]
142 ManeuverGroup,
143 #[serde(rename = "story")]
144 Story,
145}
146
147#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
149pub enum ParameterType {
150 #[serde(rename = "boolean")]
151 Boolean,
152 #[serde(rename = "dateTime")]
153 DateTime,
154 #[serde(rename = "double")]
155 Double,
156 #[serde(rename = "int")]
157 Int,
158 #[serde(rename = "string")]
159 String,
160 #[serde(rename = "unsignedInt")]
161 UnsignedInt,
162 #[serde(rename = "unsignedShort")]
163 UnsignedShort,
164}
165
166#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
168pub enum CoordinateSystem {
169 #[serde(rename = "entity")]
170 Entity,
171 #[serde(rename = "lane")]
172 Lane,
173 #[serde(rename = "road")]
174 Road,
175 #[serde(rename = "trajectory")]
176 Trajectory,
177}
178
179#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
181pub enum ReferenceContext {
182 #[serde(rename = "relative")]
183 Relative,
184 #[serde(rename = "absolute")]
185 Absolute,
186}
187
188#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
190pub enum SpeedTargetValueType {
191 #[serde(rename = "delta")]
192 Delta,
193 #[serde(rename = "absolute")]
194 Absolute,
195}
196
197#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
199pub enum DynamicsShape {
200 #[serde(rename = "linear")]
201 Linear,
202 #[serde(rename = "cubic")]
203 Cubic,
204 #[serde(rename = "sinusoidal")]
205 Sinusoidal,
206 #[serde(rename = "step")]
207 Step,
208}
209
210#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
212pub enum DynamicsDimension {
213 #[serde(rename = "rate")]
214 Rate,
215 #[serde(rename = "time")]
216 Time,
217 #[serde(rename = "distance")]
218 Distance,
219}
220
221#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
223pub enum RelativeDistanceType {
224 #[serde(rename = "longitudinal")]
225 Longitudinal,
226 #[serde(rename = "lateral")]
227 Lateral,
228 #[serde(rename = "cartesianDistance")]
229 Cartesian,
230}
231
232#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
234pub enum FollowingMode {
235 #[serde(rename = "position")]
236 Position,
237 #[serde(rename = "follow")]
238 Follow,
239}
240
241impl fmt::Display for VehicleCategory {
243 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
244 let s = match self {
245 VehicleCategory::Car => "car",
246 VehicleCategory::Van => "van",
247 VehicleCategory::Truck => "truck",
248 VehicleCategory::Semitrailer => "semitrailer",
249 VehicleCategory::Bus => "bus",
250 VehicleCategory::Motorbike => "motorbike",
251 VehicleCategory::Bicycle => "bicycle",
252 VehicleCategory::Train => "train",
253 VehicleCategory::Tram => "tram",
254 };
255 write!(f, "{}", s)
256 }
257}
258
259impl FromStr for VehicleCategory {
260 type Err = String;
261
262 fn from_str(s: &str) -> Result<Self, Self::Err> {
263 match s {
264 "car" => Ok(VehicleCategory::Car),
265 "van" => Ok(VehicleCategory::Van),
266 "truck" => Ok(VehicleCategory::Truck),
267 "semitrailer" => Ok(VehicleCategory::Semitrailer),
268 "bus" => Ok(VehicleCategory::Bus),
269 "motorbike" => Ok(VehicleCategory::Motorbike),
270 "bicycle" => Ok(VehicleCategory::Bicycle),
271 "train" => Ok(VehicleCategory::Train),
272 "tram" => Ok(VehicleCategory::Tram),
273 _ => Err(format!("Invalid vehicle category: {}", s)),
274 }
275 }
276}
277
278impl fmt::Display for Rule {
279 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
280 let s = match self {
281 Rule::EqualTo => "equalTo",
282 Rule::GreaterThan => "greaterThan",
283 Rule::LessThan => "lessThan",
284 Rule::GreaterOrEqual => "greaterOrEqual",
285 Rule::LessOrEqual => "lessOrEqual",
286 Rule::NotEqualTo => "notEqualTo",
287 };
288 write!(f, "{}", s)
289 }
290}
291
292impl FromStr for Rule {
293 type Err = String;
294
295 fn from_str(s: &str) -> Result<Self, Self::Err> {
296 match s {
297 "equalTo" => Ok(Rule::EqualTo),
298 "greaterThan" => Ok(Rule::GreaterThan),
299 "lessThan" => Ok(Rule::LessThan),
300 "greaterOrEqual" => Ok(Rule::GreaterOrEqual),
301 "lessOrEqual" => Ok(Rule::LessOrEqual),
302 "notEqualTo" => Ok(Rule::NotEqualTo),
303 _ => Err(format!("Invalid rule: {}", s)),
304 }
305 }
306}
307
308impl fmt::Display for ConditionEdge {
309 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
310 let s = match self {
311 ConditionEdge::None => "none",
312 ConditionEdge::Rising => "rising",
313 ConditionEdge::Falling => "falling",
314 ConditionEdge::RisingOrFalling => "risingOrFalling",
315 };
316 write!(f, "{}", s)
317 }
318}
319
320impl FromStr for ConditionEdge {
321 type Err = String;
322
323 fn from_str(s: &str) -> Result<Self, Self::Err> {
324 match s {
325 "none" => Ok(ConditionEdge::None),
326 "rising" => Ok(ConditionEdge::Rising),
327 "falling" => Ok(ConditionEdge::Falling),
328 "risingOrFalling" => Ok(ConditionEdge::RisingOrFalling),
329 _ => Err(format!("Invalid condition edge: {}", s)),
330 }
331 }
332}
333
334impl fmt::Display for PedestrianCategory {
335 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
336 let s = match self {
337 PedestrianCategory::Pedestrian => "pedestrian",
338 PedestrianCategory::Wheelchair => "wheelchair",
339 PedestrianCategory::Animal => "animal",
340 };
341 write!(f, "{}", s)
342 }
343}
344
345impl FromStr for PedestrianCategory {
346 type Err = String;
347
348 fn from_str(s: &str) -> Result<Self, Self::Err> {
349 match s {
350 "pedestrian" => Ok(PedestrianCategory::Pedestrian),
351 "wheelchair" => Ok(PedestrianCategory::Wheelchair),
352 "animal" => Ok(PedestrianCategory::Animal),
353 _ => Err(format!("Invalid pedestrian category: {}", s)),
354 }
355 }
356}
357
358impl fmt::Display for ObjectType {
359 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
360 let s = match self {
361 ObjectType::Vehicle => "vehicle",
362 ObjectType::Pedestrian => "pedestrian",
363 ObjectType::MiscellaneousObject => "miscellaneousObject",
364 };
365 write!(f, "{}", s)
366 }
367}
368
369impl FromStr for ObjectType {
370 type Err = String;
371
372 fn from_str(s: &str) -> Result<Self, Self::Err> {
373 match s {
374 "vehicle" => Ok(ObjectType::Vehicle),
375 "pedestrian" => Ok(ObjectType::Pedestrian),
376 "miscellaneousObject" => Ok(ObjectType::MiscellaneousObject),
377 _ => Err(format!("Invalid object type: {}", s)),
378 }
379 }
380}
381
382impl fmt::Display for RelativeDistanceType {
383 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
384 let s = match self {
385 RelativeDistanceType::Longitudinal => "longitudinal",
386 RelativeDistanceType::Lateral => "lateral",
387 RelativeDistanceType::Cartesian => "cartesianDistance",
388 };
389 write!(f, "{}", s)
390 }
391}
392
393impl FromStr for RelativeDistanceType {
394 type Err = String;
395
396 fn from_str(s: &str) -> Result<Self, Self::Err> {
397 match s {
398 "longitudinal" => Ok(RelativeDistanceType::Longitudinal),
399 "lateral" => Ok(RelativeDistanceType::Lateral),
400 "cartesianDistance" => Ok(RelativeDistanceType::Cartesian),
401 _ => Err(format!("Invalid relative distance type: {}", s)),
402 }
403 }
404}
405
406impl fmt::Display for FollowingMode {
407 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
408 let s = match self {
409 FollowingMode::Position => "position",
410 FollowingMode::Follow => "follow",
411 };
412 write!(f, "{}", s)
413 }
414}
415
416impl FromStr for FollowingMode {
417 type Err = String;
418
419 fn from_str(s: &str) -> Result<Self, Self::Err> {
420 match s {
421 "position" => Ok(FollowingMode::Position),
422 "follow" => Ok(FollowingMode::Follow),
423 _ => Err(format!("Invalid following mode: {}", s)),
424 }
425 }
426}
427
428impl fmt::Display for DynamicsDimension {
429 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
430 let s = match self {
431 DynamicsDimension::Rate => "rate",
432 DynamicsDimension::Time => "time",
433 DynamicsDimension::Distance => "distance",
434 };
435 write!(f, "{}", s)
436 }
437}
438
439impl FromStr for DynamicsDimension {
440 type Err = String;
441
442 fn from_str(s: &str) -> Result<Self, Self::Err> {
443 match s {
444 "rate" => Ok(DynamicsDimension::Rate),
445 "time" => Ok(DynamicsDimension::Time),
446 "distance" => Ok(DynamicsDimension::Distance),
447 _ => Err(format!("Invalid dynamics dimension: {}", s)),
448 }
449 }
450}
451
452#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
454pub enum MiscObjectCategory {
455 #[serde(rename = "barrier")]
456 Barrier,
457 #[serde(rename = "building")]
458 Building,
459 #[serde(rename = "crosswalk")]
460 Crosswalk,
461 #[serde(rename = "gantry")]
462 Gantry,
463 #[serde(rename = "none")]
464 None,
465 #[serde(rename = "obstacle")]
466 Obstacle,
467 #[serde(rename = "parkingSpace")]
468 ParkingSpace,
469 #[serde(rename = "patch")]
470 Patch,
471 #[serde(rename = "pole")]
472 Pole,
473 #[serde(rename = "railing")]
474 Railing,
475 #[serde(rename = "roadMark")]
476 RoadMark,
477 #[serde(rename = "soundBarrier")]
478 SoundBarrier,
479 #[serde(rename = "streetLamp")]
480 StreetLamp,
481 #[serde(rename = "trafficIsland")]
482 TrafficIsland,
483 #[serde(rename = "tree")]
484 Tree,
485 #[serde(rename = "vegetation")]
486 Vegetation,
487 #[serde(rename = "wind")]
488 Wind,
489}
490
491#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
493pub enum ControllerType {
494 #[serde(rename = "lateral")]
495 Lateral,
496 #[serde(rename = "longitudinal")]
497 Longitudinal,
498 #[serde(rename = "lighting")]
499 Lighting,
500 #[serde(rename = "animation")]
501 Animation,
502 #[serde(rename = "movement")]
503 Movement,
504 #[serde(rename = "appearance")]
505 Appearance,
506 #[serde(rename = "all")]
507 All,
508}
509
510#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
512pub enum PrecipitationType {
513 #[serde(rename = "dry")]
514 Dry,
515 #[serde(rename = "rain")]
516 Rain,
517 #[serde(rename = "snow")]
518 Snow,
519}
520
521#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
523pub enum Wetness {
524 #[serde(rename = "dry")]
525 Dry,
526 #[serde(rename = "moist")]
527 Moist,
528 #[serde(rename = "wetWithPuddles")]
529 WetWithPuddles,
530 #[serde(rename = "lowFlooded")]
531 LowFlooded,
532 #[serde(rename = "highFlooded")]
533 HighFlooded,
534}
535
536#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
538pub enum ColorType {
539 #[serde(rename = "other")]
540 Other,
541 #[serde(rename = "red")]
542 Red,
543 #[serde(rename = "yellow")]
544 Yellow,
545 #[serde(rename = "green")]
546 Green,
547 #[serde(rename = "blue")]
548 Blue,
549 #[serde(rename = "violet")]
550 Violet,
551 #[serde(rename = "orange")]
552 Orange,
553 #[serde(rename = "brown")]
554 Brown,
555 #[serde(rename = "black")]
556 Black,
557 #[serde(rename = "white")]
558 White,
559 #[serde(rename = "grey")]
560 Grey,
561}
562
563#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
565pub enum Role {
566 #[serde(rename = "none")]
567 None,
568 #[serde(rename = "ambulance")]
569 Ambulance,
570 #[serde(rename = "civil")]
571 Civil,
572 #[serde(rename = "fire")]
573 Fire,
574 #[serde(rename = "military")]
575 Military,
576 #[serde(rename = "police")]
577 Police,
578 #[serde(rename = "publicTransport")]
579 PublicTransport,
580 #[serde(rename = "roadAssistance")]
581 RoadAssistance,
582}
583
584impl fmt::Display for MiscObjectCategory {
585 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
586 let s = match self {
587 MiscObjectCategory::Barrier => "barrier",
588 MiscObjectCategory::Building => "building",
589 MiscObjectCategory::Crosswalk => "crosswalk",
590 MiscObjectCategory::Gantry => "gantry",
591 MiscObjectCategory::None => "none",
592 MiscObjectCategory::Obstacle => "obstacle",
593 MiscObjectCategory::ParkingSpace => "parkingSpace",
594 MiscObjectCategory::Patch => "patch",
595 MiscObjectCategory::Pole => "pole",
596 MiscObjectCategory::Railing => "railing",
597 MiscObjectCategory::RoadMark => "roadMark",
598 MiscObjectCategory::SoundBarrier => "soundBarrier",
599 MiscObjectCategory::StreetLamp => "streetLamp",
600 MiscObjectCategory::TrafficIsland => "trafficIsland",
601 MiscObjectCategory::Tree => "tree",
602 MiscObjectCategory::Vegetation => "vegetation",
603 MiscObjectCategory::Wind => "wind",
604 };
605 write!(f, "{}", s)
606 }
607}
608
609impl FromStr for MiscObjectCategory {
610 type Err = String;
611
612 fn from_str(s: &str) -> Result<Self, Self::Err> {
613 match s {
614 "barrier" => Ok(MiscObjectCategory::Barrier),
615 "building" => Ok(MiscObjectCategory::Building),
616 "crosswalk" => Ok(MiscObjectCategory::Crosswalk),
617 "gantry" => Ok(MiscObjectCategory::Gantry),
618 "none" => Ok(MiscObjectCategory::None),
619 "obstacle" => Ok(MiscObjectCategory::Obstacle),
620 "parkingSpace" => Ok(MiscObjectCategory::ParkingSpace),
621 "patch" => Ok(MiscObjectCategory::Patch),
622 "pole" => Ok(MiscObjectCategory::Pole),
623 "railing" => Ok(MiscObjectCategory::Railing),
624 "roadMark" => Ok(MiscObjectCategory::RoadMark),
625 "soundBarrier" => Ok(MiscObjectCategory::SoundBarrier),
626 "streetLamp" => Ok(MiscObjectCategory::StreetLamp),
627 "trafficIsland" => Ok(MiscObjectCategory::TrafficIsland),
628 "tree" => Ok(MiscObjectCategory::Tree),
629 "vegetation" => Ok(MiscObjectCategory::Vegetation),
630 "wind" => Ok(MiscObjectCategory::Wind),
631 _ => Err(format!("Invalid misc object category: {}", s)),
632 }
633 }
634}
635
636impl fmt::Display for ControllerType {
637 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
638 let s = match self {
639 ControllerType::Lateral => "lateral",
640 ControllerType::Longitudinal => "longitudinal",
641 ControllerType::Lighting => "lighting",
642 ControllerType::Animation => "animation",
643 ControllerType::Movement => "movement",
644 ControllerType::Appearance => "appearance",
645 ControllerType::All => "all",
646 };
647 write!(f, "{}", s)
648 }
649}
650
651impl FromStr for ControllerType {
652 type Err = String;
653
654 fn from_str(s: &str) -> Result<Self, Self::Err> {
655 match s {
656 "lateral" => Ok(ControllerType::Lateral),
657 "longitudinal" => Ok(ControllerType::Longitudinal),
658 "lighting" => Ok(ControllerType::Lighting),
659 "animation" => Ok(ControllerType::Animation),
660 "movement" => Ok(ControllerType::Movement),
661 "appearance" => Ok(ControllerType::Appearance),
662 "all" => Ok(ControllerType::All),
663 _ => Err(format!("Invalid controller type: {}", s)),
664 }
665 }
666}
667
668impl fmt::Display for PrecipitationType {
669 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
670 let s = match self {
671 PrecipitationType::Dry => "dry",
672 PrecipitationType::Rain => "rain",
673 PrecipitationType::Snow => "snow",
674 };
675 write!(f, "{}", s)
676 }
677}
678
679impl FromStr for PrecipitationType {
680 type Err = String;
681
682 fn from_str(s: &str) -> Result<Self, Self::Err> {
683 match s {
684 "dry" => Ok(PrecipitationType::Dry),
685 "rain" => Ok(PrecipitationType::Rain),
686 "snow" => Ok(PrecipitationType::Snow),
687 _ => Err(format!("Invalid precipitation type: {}", s)),
688 }
689 }
690}
691
692impl fmt::Display for Wetness {
693 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
694 let s = match self {
695 Wetness::Dry => "dry",
696 Wetness::Moist => "moist",
697 Wetness::WetWithPuddles => "wetWithPuddles",
698 Wetness::LowFlooded => "lowFlooded",
699 Wetness::HighFlooded => "highFlooded",
700 };
701 write!(f, "{}", s)
702 }
703}
704
705impl FromStr for Wetness {
706 type Err = String;
707
708 fn from_str(s: &str) -> Result<Self, Self::Err> {
709 match s {
710 "dry" => Ok(Wetness::Dry),
711 "moist" => Ok(Wetness::Moist),
712 "wetWithPuddles" => Ok(Wetness::WetWithPuddles),
713 "lowFlooded" => Ok(Wetness::LowFlooded),
714 "highFlooded" => Ok(Wetness::HighFlooded),
715 _ => Err(format!("Invalid wetness: {}", s)),
716 }
717 }
718}
719
720impl fmt::Display for ColorType {
721 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
722 let s = match self {
723 ColorType::Other => "other",
724 ColorType::Red => "red",
725 ColorType::Yellow => "yellow",
726 ColorType::Green => "green",
727 ColorType::Blue => "blue",
728 ColorType::Violet => "violet",
729 ColorType::Orange => "orange",
730 ColorType::Brown => "brown",
731 ColorType::Black => "black",
732 ColorType::White => "white",
733 ColorType::Grey => "grey",
734 };
735 write!(f, "{}", s)
736 }
737}
738
739impl FromStr for ColorType {
740 type Err = String;
741
742 fn from_str(s: &str) -> Result<Self, Self::Err> {
743 match s {
744 "other" => Ok(ColorType::Other),
745 "red" => Ok(ColorType::Red),
746 "yellow" => Ok(ColorType::Yellow),
747 "green" => Ok(ColorType::Green),
748 "blue" => Ok(ColorType::Blue),
749 "violet" => Ok(ColorType::Violet),
750 "orange" => Ok(ColorType::Orange),
751 "brown" => Ok(ColorType::Brown),
752 "black" => Ok(ColorType::Black),
753 "white" => Ok(ColorType::White),
754 "grey" => Ok(ColorType::Grey),
755 _ => Err(format!("Invalid color type: {}", s)),
756 }
757 }
758}
759
760impl fmt::Display for Role {
761 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
762 let s = match self {
763 Role::None => "none",
764 Role::Ambulance => "ambulance",
765 Role::Civil => "civil",
766 Role::Fire => "fire",
767 Role::Military => "military",
768 Role::Police => "police",
769 Role::PublicTransport => "publicTransport",
770 Role::RoadAssistance => "roadAssistance",
771 };
772 write!(f, "{}", s)
773 }
774}
775
776impl FromStr for Role {
777 type Err = String;
778
779 fn from_str(s: &str) -> Result<Self, Self::Err> {
780 match s {
781 "none" => Ok(Role::None),
782 "ambulance" => Ok(Role::Ambulance),
783 "civil" => Ok(Role::Civil),
784 "fire" => Ok(Role::Fire),
785 "military" => Ok(Role::Military),
786 "police" => Ok(Role::Police),
787 "publicTransport" => Ok(Role::PublicTransport),
788 "roadAssistance" => Ok(Role::RoadAssistance),
789 _ => Err(format!("Invalid role: {}", s)),
790 }
791 }
792}
793
794#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
796pub enum AngleType {
797 #[serde(rename = "relative")]
798 Relative,
799 #[serde(rename = "absolute")]
800 Absolute,
801}
802
803#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
805pub enum DirectionalDimension {
806 #[serde(rename = "longitudinal")]
807 Longitudinal,
808 #[serde(rename = "lateral")]
809 Lateral,
810 #[serde(rename = "vertical")]
811 Vertical,
812}
813
814#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
816pub enum VehicleComponentType {
817 #[serde(rename = "hood")]
818 Hood,
819 #[serde(rename = "trunk")]
820 Trunk,
821 #[serde(rename = "doorFrontLeft")]
822 DoorFrontLeft,
823 #[serde(rename = "doorFrontRight")]
824 DoorFrontRight,
825 #[serde(rename = "doorRearLeft")]
826 DoorRearLeft,
827 #[serde(rename = "doorRearRight")]
828 DoorRearRight,
829 #[serde(rename = "windowFrontLeft")]
830 WindowFrontLeft,
831 #[serde(rename = "windowFrontRight")]
832 WindowFrontRight,
833 #[serde(rename = "windowRearLeft")]
834 WindowRearLeft,
835 #[serde(rename = "windowRearRight")]
836 WindowRearRight,
837}
838
839#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
841pub enum VehicleLightType {
842 #[serde(rename = "headlight")]
843 Headlight,
844 #[serde(rename = "taillight")]
845 Taillight,
846 #[serde(rename = "brakeLight")]
847 BrakeLight,
848 #[serde(rename = "reverseLight")]
849 ReverseLight,
850 #[serde(rename = "indicatorLeft")]
851 IndicatorLeft,
852 #[serde(rename = "indicatorRight")]
853 IndicatorRight,
854 #[serde(rename = "warningLight")]
855 WarningLight,
856 #[serde(rename = "fogLight")]
857 FogLight,
858 #[serde(rename = "highBeam")]
859 HighBeam,
860 #[serde(rename = "licensePlateLight")]
861 LicensePlateLight,
862}
863
864#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
866pub enum LightMode {
867 #[serde(rename = "on")]
868 On,
869 #[serde(rename = "off")]
870 Off,
871 #[serde(rename = "flashing")]
872 Flashing,
873}
874
875#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
877pub enum AutomaticGearType {
878 #[serde(rename = "n")]
879 Neutral,
880 #[serde(rename = "p")]
881 Park,
882 #[serde(rename = "r")]
883 Reverse,
884 #[serde(rename = "d")]
885 Drive,
886}
887
888#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
890pub enum FractionalCloudCover {
891 #[serde(rename = "zeroOktas")]
892 ZeroOktas,
893 #[serde(rename = "oneOktas")]
894 OneOktas,
895 #[serde(rename = "twoOktas")]
896 TwoOktas,
897 #[serde(rename = "threeOktas")]
898 ThreeOktas,
899 #[serde(rename = "fourOktas")]
900 FourOktas,
901 #[serde(rename = "fiveOktas")]
902 FiveOktas,
903 #[serde(rename = "sixOktas")]
904 SixOktas,
905 #[serde(rename = "sevenOktas")]
906 SevenOktas,
907 #[serde(rename = "eightOktas")]
908 EightOktas,
909 #[serde(rename = "nineOktas")]
910 NineOktas,
911}
912
913#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
915pub enum PedestrianMotionType {
916 #[serde(rename = "standing")]
917 Standing,
918 #[serde(rename = "sitting")]
919 Sitting,
920 #[serde(rename = "lying")]
921 Lying,
922 #[serde(rename = "squatting")]
923 Squatting,
924 #[serde(rename = "walking")]
925 Walking,
926 #[serde(rename = "running")]
927 Running,
928 #[serde(rename = "reeling")]
929 Reeling,
930 #[serde(rename = "crawling")]
931 Crawling,
932 #[serde(rename = "cycling")]
933 Cycling,
934 #[serde(rename = "jumping")]
935 Jumping,
936 #[serde(rename = "ducking")]
937 Ducking,
938 #[serde(rename = "bendingDown")]
939 BendingDown,
940}
941
942#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
944pub enum PedestrianGestureType {
945 #[serde(rename = "phoneCallRightHand")]
946 PhoneCallRightHand,
947 #[serde(rename = "phoneCallLeftHand")]
948 PhoneCallLeftHand,
949 #[serde(rename = "phoneTextRightHand")]
950 PhoneTextRightHand,
951 #[serde(rename = "phoneTextLeftHand")]
952 PhoneTextLeftHand,
953 #[serde(rename = "wavingRightArm")]
954 WavingRightArm,
955 #[serde(rename = "wavingLeftArm")]
956 WavingLeftArm,
957 #[serde(rename = "umbrellaRightHand")]
958 UmbrellaRightHand,
959 #[serde(rename = "umbrellaLeftHand")]
960 UmbrellaLeftHand,
961 #[serde(rename = "crossArms")]
962 CrossArms,
963 #[serde(rename = "coffeeRightHand")]
964 CoffeeRightHand,
965 #[serde(rename = "coffeeLeftHand")]
966 CoffeeLeftHand,
967 #[serde(rename = "sandwichRightHand")]
968 SandwichRightHand,
969 #[serde(rename = "sandwichLeftHand")]
970 SandwichLeftHand,
971}
972
973#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
975pub enum RouteStrategy {
976 #[serde(rename = "fastest")]
977 Fastest,
978 #[serde(rename = "leastIntersections")]
979 LeastIntersections,
980 #[serde(rename = "random")]
981 Random,
982 #[serde(rename = "shortest")]
983 Shortest,
984}
985
986#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
988pub enum RoutingAlgorithm {
989 #[serde(rename = "assignedRoute")]
990 AssignedRoute,
991 #[serde(rename = "fastest")]
992 Fastest,
993 #[serde(rename = "leastIntersections")]
994 LeastIntersections,
995 #[serde(rename = "shortest")]
996 Shortest,
997 #[serde(rename = "undefined")]
998 Undefined,
999}
1000
1001impl fmt::Display for AngleType {
1002 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1003 let s = match self {
1004 AngleType::Relative => "relative",
1005 AngleType::Absolute => "absolute",
1006 };
1007 write!(f, "{}", s)
1008 }
1009}
1010
1011impl FromStr for AngleType {
1012 type Err = String;
1013
1014 fn from_str(s: &str) -> Result<Self, Self::Err> {
1015 match s {
1016 "relative" => Ok(AngleType::Relative),
1017 "absolute" => Ok(AngleType::Absolute),
1018 _ => Err(format!("Invalid angle type: {}", s)),
1019 }
1020 }
1021}
1022
1023impl fmt::Display for DirectionalDimension {
1024 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1025 let s = match self {
1026 DirectionalDimension::Longitudinal => "longitudinal",
1027 DirectionalDimension::Lateral => "lateral",
1028 DirectionalDimension::Vertical => "vertical",
1029 };
1030 write!(f, "{}", s)
1031 }
1032}
1033
1034impl FromStr for DirectionalDimension {
1035 type Err = String;
1036
1037 fn from_str(s: &str) -> Result<Self, Self::Err> {
1038 match s {
1039 "longitudinal" => Ok(DirectionalDimension::Longitudinal),
1040 "lateral" => Ok(DirectionalDimension::Lateral),
1041 "vertical" => Ok(DirectionalDimension::Vertical),
1042 _ => Err(format!("Invalid directional dimension: {}", s)),
1043 }
1044 }
1045}
1046
1047impl fmt::Display for VehicleComponentType {
1048 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1049 let s = match self {
1050 VehicleComponentType::Hood => "hood",
1051 VehicleComponentType::Trunk => "trunk",
1052 VehicleComponentType::DoorFrontLeft => "doorFrontLeft",
1053 VehicleComponentType::DoorFrontRight => "doorFrontRight",
1054 VehicleComponentType::DoorRearLeft => "doorRearLeft",
1055 VehicleComponentType::DoorRearRight => "doorRearRight",
1056 VehicleComponentType::WindowFrontLeft => "windowFrontLeft",
1057 VehicleComponentType::WindowFrontRight => "windowFrontRight",
1058 VehicleComponentType::WindowRearLeft => "windowRearLeft",
1059 VehicleComponentType::WindowRearRight => "windowRearRight",
1060 };
1061 write!(f, "{}", s)
1062 }
1063}
1064
1065impl FromStr for VehicleComponentType {
1066 type Err = String;
1067
1068 fn from_str(s: &str) -> Result<Self, Self::Err> {
1069 match s {
1070 "hood" => Ok(VehicleComponentType::Hood),
1071 "trunk" => Ok(VehicleComponentType::Trunk),
1072 "doorFrontLeft" => Ok(VehicleComponentType::DoorFrontLeft),
1073 "doorFrontRight" => Ok(VehicleComponentType::DoorFrontRight),
1074 "doorRearLeft" => Ok(VehicleComponentType::DoorRearLeft),
1075 "doorRearRight" => Ok(VehicleComponentType::DoorRearRight),
1076 "windowFrontLeft" => Ok(VehicleComponentType::WindowFrontLeft),
1077 "windowFrontRight" => Ok(VehicleComponentType::WindowFrontRight),
1078 "windowRearLeft" => Ok(VehicleComponentType::WindowRearLeft),
1079 "windowRearRight" => Ok(VehicleComponentType::WindowRearRight),
1080 _ => Err(format!("Invalid vehicle component type: {}", s)),
1081 }
1082 }
1083}
1084
1085impl fmt::Display for VehicleLightType {
1086 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1087 let s = match self {
1088 VehicleLightType::Headlight => "headlight",
1089 VehicleLightType::Taillight => "taillight",
1090 VehicleLightType::BrakeLight => "brakeLight",
1091 VehicleLightType::ReverseLight => "reverseLight",
1092 VehicleLightType::IndicatorLeft => "indicatorLeft",
1093 VehicleLightType::IndicatorRight => "indicatorRight",
1094 VehicleLightType::WarningLight => "warningLight",
1095 VehicleLightType::FogLight => "fogLight",
1096 VehicleLightType::HighBeam => "highBeam",
1097 VehicleLightType::LicensePlateLight => "licensePlateLight",
1098 };
1099 write!(f, "{}", s)
1100 }
1101}
1102
1103impl FromStr for VehicleLightType {
1104 type Err = String;
1105
1106 fn from_str(s: &str) -> Result<Self, Self::Err> {
1107 match s {
1108 "headlight" => Ok(VehicleLightType::Headlight),
1109 "taillight" => Ok(VehicleLightType::Taillight),
1110 "brakeLight" => Ok(VehicleLightType::BrakeLight),
1111 "reverseLight" => Ok(VehicleLightType::ReverseLight),
1112 "indicatorLeft" => Ok(VehicleLightType::IndicatorLeft),
1113 "indicatorRight" => Ok(VehicleLightType::IndicatorRight),
1114 "warningLight" => Ok(VehicleLightType::WarningLight),
1115 "fogLight" => Ok(VehicleLightType::FogLight),
1116 "highBeam" => Ok(VehicleLightType::HighBeam),
1117 "licensePlateLight" => Ok(VehicleLightType::LicensePlateLight),
1118 _ => Err(format!("Invalid vehicle light type: {}", s)),
1119 }
1120 }
1121}
1122
1123impl fmt::Display for LightMode {
1124 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1125 let s = match self {
1126 LightMode::On => "on",
1127 LightMode::Off => "off",
1128 LightMode::Flashing => "flashing",
1129 };
1130 write!(f, "{}", s)
1131 }
1132}
1133
1134impl FromStr for LightMode {
1135 type Err = String;
1136
1137 fn from_str(s: &str) -> Result<Self, Self::Err> {
1138 match s {
1139 "on" => Ok(LightMode::On),
1140 "off" => Ok(LightMode::Off),
1141 "flashing" => Ok(LightMode::Flashing),
1142 _ => Err(format!("Invalid light mode: {}", s)),
1143 }
1144 }
1145}
1146
1147impl fmt::Display for AutomaticGearType {
1148 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1149 let s = match self {
1150 AutomaticGearType::Neutral => "n",
1151 AutomaticGearType::Park => "p",
1152 AutomaticGearType::Reverse => "r",
1153 AutomaticGearType::Drive => "d",
1154 };
1155 write!(f, "{}", s)
1156 }
1157}
1158
1159impl FromStr for AutomaticGearType {
1160 type Err = String;
1161
1162 fn from_str(s: &str) -> Result<Self, Self::Err> {
1163 match s {
1164 "n" => Ok(AutomaticGearType::Neutral),
1165 "p" => Ok(AutomaticGearType::Park),
1166 "r" => Ok(AutomaticGearType::Reverse),
1167 "d" => Ok(AutomaticGearType::Drive),
1168 _ => Err(format!("Invalid automatic gear type: {}", s)),
1169 }
1170 }
1171}
1172
1173impl fmt::Display for FractionalCloudCover {
1174 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1175 let s = match self {
1176 FractionalCloudCover::ZeroOktas => "zeroOktas",
1177 FractionalCloudCover::OneOktas => "oneOktas",
1178 FractionalCloudCover::TwoOktas => "twoOktas",
1179 FractionalCloudCover::ThreeOktas => "threeOktas",
1180 FractionalCloudCover::FourOktas => "fourOktas",
1181 FractionalCloudCover::FiveOktas => "fiveOktas",
1182 FractionalCloudCover::SixOktas => "sixOktas",
1183 FractionalCloudCover::SevenOktas => "sevenOktas",
1184 FractionalCloudCover::EightOktas => "eightOktas",
1185 FractionalCloudCover::NineOktas => "nineOktas",
1186 };
1187 write!(f, "{}", s)
1188 }
1189}
1190
1191impl FromStr for FractionalCloudCover {
1192 type Err = String;
1193
1194 fn from_str(s: &str) -> Result<Self, Self::Err> {
1195 match s {
1196 "zeroOktas" => Ok(FractionalCloudCover::ZeroOktas),
1197 "oneOktas" => Ok(FractionalCloudCover::OneOktas),
1198 "twoOktas" => Ok(FractionalCloudCover::TwoOktas),
1199 "threeOktas" => Ok(FractionalCloudCover::ThreeOktas),
1200 "fourOktas" => Ok(FractionalCloudCover::FourOktas),
1201 "fiveOktas" => Ok(FractionalCloudCover::FiveOktas),
1202 "sixOktas" => Ok(FractionalCloudCover::SixOktas),
1203 "sevenOktas" => Ok(FractionalCloudCover::SevenOktas),
1204 "eightOktas" => Ok(FractionalCloudCover::EightOktas),
1205 "nineOktas" => Ok(FractionalCloudCover::NineOktas),
1206 _ => Err(format!("Invalid fractional cloud cover: {}", s)),
1207 }
1208 }
1209}
1210
1211impl fmt::Display for PedestrianMotionType {
1212 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1213 let s = match self {
1214 PedestrianMotionType::Standing => "standing",
1215 PedestrianMotionType::Sitting => "sitting",
1216 PedestrianMotionType::Lying => "lying",
1217 PedestrianMotionType::Squatting => "squatting",
1218 PedestrianMotionType::Walking => "walking",
1219 PedestrianMotionType::Running => "running",
1220 PedestrianMotionType::Reeling => "reeling",
1221 PedestrianMotionType::Crawling => "crawling",
1222 PedestrianMotionType::Cycling => "cycling",
1223 PedestrianMotionType::Jumping => "jumping",
1224 PedestrianMotionType::Ducking => "ducking",
1225 PedestrianMotionType::BendingDown => "bendingDown",
1226 };
1227 write!(f, "{}", s)
1228 }
1229}
1230
1231impl FromStr for PedestrianMotionType {
1232 type Err = String;
1233
1234 fn from_str(s: &str) -> Result<Self, Self::Err> {
1235 match s {
1236 "standing" => Ok(PedestrianMotionType::Standing),
1237 "sitting" => Ok(PedestrianMotionType::Sitting),
1238 "lying" => Ok(PedestrianMotionType::Lying),
1239 "squatting" => Ok(PedestrianMotionType::Squatting),
1240 "walking" => Ok(PedestrianMotionType::Walking),
1241 "running" => Ok(PedestrianMotionType::Running),
1242 "reeling" => Ok(PedestrianMotionType::Reeling),
1243 "crawling" => Ok(PedestrianMotionType::Crawling),
1244 "cycling" => Ok(PedestrianMotionType::Cycling),
1245 "jumping" => Ok(PedestrianMotionType::Jumping),
1246 "ducking" => Ok(PedestrianMotionType::Ducking),
1247 "bendingDown" => Ok(PedestrianMotionType::BendingDown),
1248 _ => Err(format!("Invalid pedestrian motion type: {}", s)),
1249 }
1250 }
1251}
1252
1253impl fmt::Display for PedestrianGestureType {
1254 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1255 let s = match self {
1256 PedestrianGestureType::PhoneCallRightHand => "phoneCallRightHand",
1257 PedestrianGestureType::PhoneCallLeftHand => "phoneCallLeftHand",
1258 PedestrianGestureType::PhoneTextRightHand => "phoneTextRightHand",
1259 PedestrianGestureType::PhoneTextLeftHand => "phoneTextLeftHand",
1260 PedestrianGestureType::WavingRightArm => "wavingRightArm",
1261 PedestrianGestureType::WavingLeftArm => "wavingLeftArm",
1262 PedestrianGestureType::UmbrellaRightHand => "umbrellaRightHand",
1263 PedestrianGestureType::UmbrellaLeftHand => "umbrellaLeftHand",
1264 PedestrianGestureType::CrossArms => "crossArms",
1265 PedestrianGestureType::CoffeeRightHand => "coffeeRightHand",
1266 PedestrianGestureType::CoffeeLeftHand => "coffeeLeftHand",
1267 PedestrianGestureType::SandwichRightHand => "sandwichRightHand",
1268 PedestrianGestureType::SandwichLeftHand => "sandwichLeftHand",
1269 };
1270 write!(f, "{}", s)
1271 }
1272}
1273
1274impl FromStr for PedestrianGestureType {
1275 type Err = String;
1276
1277 fn from_str(s: &str) -> Result<Self, Self::Err> {
1278 match s {
1279 "phoneCallRightHand" => Ok(PedestrianGestureType::PhoneCallRightHand),
1280 "phoneCallLeftHand" => Ok(PedestrianGestureType::PhoneCallLeftHand),
1281 "phoneTextRightHand" => Ok(PedestrianGestureType::PhoneTextRightHand),
1282 "phoneTextLeftHand" => Ok(PedestrianGestureType::PhoneTextLeftHand),
1283 "wavingRightArm" => Ok(PedestrianGestureType::WavingRightArm),
1284 "wavingLeftArm" => Ok(PedestrianGestureType::WavingLeftArm),
1285 "umbrellaRightHand" => Ok(PedestrianGestureType::UmbrellaRightHand),
1286 "umbrellaLeftHand" => Ok(PedestrianGestureType::UmbrellaLeftHand),
1287 "crossArms" => Ok(PedestrianGestureType::CrossArms),
1288 "coffeeRightHand" => Ok(PedestrianGestureType::CoffeeRightHand),
1289 "coffeeLeftHand" => Ok(PedestrianGestureType::CoffeeLeftHand),
1290 "sandwichRightHand" => Ok(PedestrianGestureType::SandwichRightHand),
1291 "sandwichLeftHand" => Ok(PedestrianGestureType::SandwichLeftHand),
1292 _ => Err(format!("Invalid pedestrian gesture type: {}", s)),
1293 }
1294 }
1295}
1296
1297impl fmt::Display for RouteStrategy {
1298 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1299 let s = match self {
1300 RouteStrategy::Fastest => "fastest",
1301 RouteStrategy::LeastIntersections => "leastIntersections",
1302 RouteStrategy::Random => "random",
1303 RouteStrategy::Shortest => "shortest",
1304 };
1305 write!(f, "{}", s)
1306 }
1307}
1308
1309impl FromStr for RouteStrategy {
1310 type Err = String;
1311
1312 fn from_str(s: &str) -> Result<Self, Self::Err> {
1313 match s {
1314 "fastest" => Ok(RouteStrategy::Fastest),
1315 "leastIntersections" => Ok(RouteStrategy::LeastIntersections),
1316 "random" => Ok(RouteStrategy::Random),
1317 "shortest" => Ok(RouteStrategy::Shortest),
1318 _ => Err(format!("Invalid route strategy: {}", s)),
1319 }
1320 }
1321}
1322
1323impl fmt::Display for RoutingAlgorithm {
1324 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1325 let s = match self {
1326 RoutingAlgorithm::AssignedRoute => "assignedRoute",
1327 RoutingAlgorithm::Fastest => "fastest",
1328 RoutingAlgorithm::LeastIntersections => "leastIntersections",
1329 RoutingAlgorithm::Shortest => "shortest",
1330 RoutingAlgorithm::Undefined => "undefined",
1331 };
1332 write!(f, "{}", s)
1333 }
1334}
1335
1336impl FromStr for RoutingAlgorithm {
1337 type Err = String;
1338
1339 fn from_str(s: &str) -> Result<Self, Self::Err> {
1340 match s {
1341 "assignedRoute" => Ok(RoutingAlgorithm::AssignedRoute),
1342 "fastest" => Ok(RoutingAlgorithm::Fastest),
1343 "leastIntersections" => Ok(RoutingAlgorithm::LeastIntersections),
1344 "shortest" => Ok(RoutingAlgorithm::Shortest),
1345 "undefined" => Ok(RoutingAlgorithm::Undefined),
1346 _ => Err(format!("Invalid routing algorithm: {}", s)),
1347 }
1348 }
1349}
1350
1351#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1353pub enum LateralDisplacement {
1354 #[serde(rename = "any")]
1355 Any,
1356 #[serde(rename = "leftToReferencedEntity")]
1357 LeftToReferencedEntity,
1358 #[serde(rename = "rightToReferencedEntity")]
1359 RightToReferencedEntity,
1360}
1361
1362#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1364pub enum LongitudinalDisplacement {
1365 #[serde(rename = "any")]
1366 Any,
1367 #[serde(rename = "trailingReferencedEntity")]
1368 TrailingReferencedEntity,
1369 #[serde(rename = "leadingReferencedEntity")]
1370 LeadingReferencedEntity,
1371}
1372
1373#[deprecated(note = "CloudState is deprecated, use FractionalCloudCover instead")]
1375#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1376pub enum CloudState {
1377 #[serde(rename = "cloudy")]
1378 Cloudy,
1379 #[serde(rename = "free")]
1380 Free,
1381 #[serde(rename = "overcast")]
1382 Overcast,
1383 #[serde(rename = "rainy")]
1384 Rainy,
1385 #[serde(rename = "skyOff")]
1386 SkyOff,
1387}
1388
1389impl fmt::Display for LateralDisplacement {
1390 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1391 let s = match self {
1392 LateralDisplacement::Any => "any",
1393 LateralDisplacement::LeftToReferencedEntity => "leftToReferencedEntity",
1394 LateralDisplacement::RightToReferencedEntity => "rightToReferencedEntity",
1395 };
1396 write!(f, "{}", s)
1397 }
1398}
1399
1400impl FromStr for LateralDisplacement {
1401 type Err = String;
1402
1403 fn from_str(s: &str) -> Result<Self, Self::Err> {
1404 match s {
1405 "any" => Ok(LateralDisplacement::Any),
1406 "leftToReferencedEntity" => Ok(LateralDisplacement::LeftToReferencedEntity),
1407 "rightToReferencedEntity" => Ok(LateralDisplacement::RightToReferencedEntity),
1408 _ => Err(format!("Invalid lateral displacement: {}", s)),
1409 }
1410 }
1411}
1412
1413impl fmt::Display for LongitudinalDisplacement {
1414 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1415 let s = match self {
1416 LongitudinalDisplacement::Any => "any",
1417 LongitudinalDisplacement::TrailingReferencedEntity => "trailingReferencedEntity",
1418 LongitudinalDisplacement::LeadingReferencedEntity => "leadingReferencedEntity",
1419 };
1420 write!(f, "{}", s)
1421 }
1422}
1423
1424impl FromStr for LongitudinalDisplacement {
1425 type Err = String;
1426
1427 fn from_str(s: &str) -> Result<Self, Self::Err> {
1428 match s {
1429 "any" => Ok(LongitudinalDisplacement::Any),
1430 "trailingReferencedEntity" => Ok(LongitudinalDisplacement::TrailingReferencedEntity),
1431 "leadingReferencedEntity" => Ok(LongitudinalDisplacement::LeadingReferencedEntity),
1432 _ => Err(format!("Invalid longitudinal displacement: {}", s)),
1433 }
1434 }
1435}
1436
1437impl fmt::Display for CloudState {
1438 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1439 let s = match self {
1440 CloudState::Cloudy => "cloudy",
1441 CloudState::Free => "free",
1442 CloudState::Overcast => "overcast",
1443 CloudState::Rainy => "rainy",
1444 CloudState::SkyOff => "skyOff",
1445 };
1446 write!(f, "{}", s)
1447 }
1448}
1449
1450impl FromStr for CloudState {
1451 type Err = String;
1452
1453 fn from_str(s: &str) -> Result<Self, Self::Err> {
1454 match s {
1455 "cloudy" => Ok(CloudState::Cloudy),
1456 "free" => Ok(CloudState::Free),
1457 "overcast" => Ok(CloudState::Overcast),
1458 "rainy" => Ok(CloudState::Rainy),
1459 "skyOff" => Ok(CloudState::SkyOff),
1460 _ => Err(s.to_string()),
1461 }
1462 }
1463}
1464
1465#[cfg(test)]
1466mod tests {
1467 use super::*;
1468
1469 #[test]
1470 fn test_vehicle_category_display() {
1471 assert_eq!(VehicleCategory::Car.to_string(), "car");
1472 assert_eq!(VehicleCategory::Truck.to_string(), "truck");
1473 }
1474
1475 #[test]
1476 fn test_vehicle_category_from_str() {
1477 assert_eq!(
1478 "car".parse::<VehicleCategory>().unwrap(),
1479 VehicleCategory::Car
1480 );
1481 assert_eq!(
1482 "truck".parse::<VehicleCategory>().unwrap(),
1483 VehicleCategory::Truck
1484 );
1485 assert!("invalid".parse::<VehicleCategory>().is_err());
1486 }
1487
1488 #[test]
1489 fn test_rule_display() {
1490 assert_eq!(Rule::EqualTo.to_string(), "equalTo");
1491 assert_eq!(Rule::GreaterThan.to_string(), "greaterThan");
1492 }
1493
1494 #[test]
1495 fn test_misc_object_category_display() {
1496 assert_eq!(MiscObjectCategory::Barrier.to_string(), "barrier");
1497 assert_eq!(MiscObjectCategory::Building.to_string(), "building");
1498 assert_eq!(MiscObjectCategory::None.to_string(), "none");
1499 }
1500
1501 #[test]
1502 fn test_misc_object_category_from_str() {
1503 assert_eq!(
1504 "barrier".parse::<MiscObjectCategory>().unwrap(),
1505 MiscObjectCategory::Barrier
1506 );
1507 assert_eq!(
1508 "obstacle".parse::<MiscObjectCategory>().unwrap(),
1509 MiscObjectCategory::Obstacle
1510 );
1511 assert!("invalid".parse::<MiscObjectCategory>().is_err());
1512 }
1513
1514 #[test]
1515 fn test_controller_type_display() {
1516 assert_eq!(ControllerType::Lateral.to_string(), "lateral");
1517 assert_eq!(ControllerType::All.to_string(), "all");
1518 }
1519
1520 #[test]
1521 fn test_precipitation_type_display() {
1522 assert_eq!(PrecipitationType::Dry.to_string(), "dry");
1523 assert_eq!(PrecipitationType::Rain.to_string(), "rain");
1524 }
1525
1526 #[test]
1527 fn test_wetness_display() {
1528 assert_eq!(Wetness::Dry.to_string(), "dry");
1529 assert_eq!(Wetness::WetWithPuddles.to_string(), "wetWithPuddles");
1530 }
1531
1532 #[test]
1533 fn test_color_type_display() {
1534 assert_eq!(ColorType::Red.to_string(), "red");
1535 assert_eq!(ColorType::Blue.to_string(), "blue");
1536 }
1537
1538 #[test]
1539 fn test_role_display() {
1540 assert_eq!(Role::None.to_string(), "none");
1541 assert_eq!(Role::Police.to_string(), "police");
1542 }
1543
1544 #[test]
1545 fn test_angle_type_display() {
1546 assert_eq!(AngleType::Relative.to_string(), "relative");
1547 assert_eq!(AngleType::Absolute.to_string(), "absolute");
1548 }
1549
1550 #[test]
1551 fn test_angle_type_from_str() {
1552 assert_eq!(
1553 "relative".parse::<AngleType>().unwrap(),
1554 AngleType::Relative
1555 );
1556 assert_eq!(
1557 "absolute".parse::<AngleType>().unwrap(),
1558 AngleType::Absolute
1559 );
1560 assert!("invalid".parse::<AngleType>().is_err());
1561 }
1562
1563 #[test]
1564 fn test_directional_dimension_display() {
1565 assert_eq!(
1566 DirectionalDimension::Longitudinal.to_string(),
1567 "longitudinal"
1568 );
1569 assert_eq!(DirectionalDimension::Lateral.to_string(), "lateral");
1570 assert_eq!(DirectionalDimension::Vertical.to_string(), "vertical");
1571 }
1572
1573 #[test]
1574 fn test_vehicle_component_type_display() {
1575 assert_eq!(VehicleComponentType::Hood.to_string(), "hood");
1576 assert_eq!(
1577 VehicleComponentType::DoorFrontLeft.to_string(),
1578 "doorFrontLeft"
1579 );
1580 }
1581
1582 #[test]
1583 fn test_vehicle_light_type_display() {
1584 assert_eq!(VehicleLightType::Headlight.to_string(), "headlight");
1585 assert_eq!(VehicleLightType::BrakeLight.to_string(), "brakeLight");
1586 }
1587
1588 #[test]
1589 fn test_light_mode_display() {
1590 assert_eq!(LightMode::On.to_string(), "on");
1591 assert_eq!(LightMode::Off.to_string(), "off");
1592 assert_eq!(LightMode::Flashing.to_string(), "flashing");
1593 }
1594
1595 #[test]
1596 fn test_automatic_gear_type_display() {
1597 assert_eq!(AutomaticGearType::Neutral.to_string(), "n");
1598 assert_eq!(AutomaticGearType::Park.to_string(), "p");
1599 assert_eq!(AutomaticGearType::Reverse.to_string(), "r");
1600 assert_eq!(AutomaticGearType::Drive.to_string(), "d");
1601 }
1602
1603 #[test]
1604 fn test_automatic_gear_type_from_str() {
1605 assert_eq!(
1606 "n".parse::<AutomaticGearType>().unwrap(),
1607 AutomaticGearType::Neutral
1608 );
1609 assert_eq!(
1610 "p".parse::<AutomaticGearType>().unwrap(),
1611 AutomaticGearType::Park
1612 );
1613 assert_eq!(
1614 "r".parse::<AutomaticGearType>().unwrap(),
1615 AutomaticGearType::Reverse
1616 );
1617 assert_eq!(
1618 "d".parse::<AutomaticGearType>().unwrap(),
1619 AutomaticGearType::Drive
1620 );
1621 assert!("invalid".parse::<AutomaticGearType>().is_err());
1622 }
1623
1624 #[test]
1625 fn test_fractional_cloud_cover_display() {
1626 assert_eq!(FractionalCloudCover::ZeroOktas.to_string(), "zeroOktas");
1627 assert_eq!(FractionalCloudCover::FiveOktas.to_string(), "fiveOktas");
1628 assert_eq!(FractionalCloudCover::NineOktas.to_string(), "nineOktas");
1629 }
1630
1631 #[test]
1632 fn test_fractional_cloud_cover_from_str() {
1633 assert_eq!(
1634 "zeroOktas".parse::<FractionalCloudCover>().unwrap(),
1635 FractionalCloudCover::ZeroOktas
1636 );
1637 assert_eq!(
1638 "fiveOktas".parse::<FractionalCloudCover>().unwrap(),
1639 FractionalCloudCover::FiveOktas
1640 );
1641 assert_eq!(
1642 "nineOktas".parse::<FractionalCloudCover>().unwrap(),
1643 FractionalCloudCover::NineOktas
1644 );
1645 assert!("invalid".parse::<FractionalCloudCover>().is_err());
1646 }
1647
1648 #[test]
1649 fn test_pedestrian_motion_type_display() {
1650 assert_eq!(PedestrianMotionType::Standing.to_string(), "standing");
1651 assert_eq!(PedestrianMotionType::Walking.to_string(), "walking");
1652 assert_eq!(PedestrianMotionType::Running.to_string(), "running");
1653 assert_eq!(PedestrianMotionType::BendingDown.to_string(), "bendingDown");
1654 }
1655
1656 #[test]
1657 fn test_pedestrian_motion_type_from_str() {
1658 assert_eq!(
1659 "standing".parse::<PedestrianMotionType>().unwrap(),
1660 PedestrianMotionType::Standing
1661 );
1662 assert_eq!(
1663 "walking".parse::<PedestrianMotionType>().unwrap(),
1664 PedestrianMotionType::Walking
1665 );
1666 assert_eq!(
1667 "running".parse::<PedestrianMotionType>().unwrap(),
1668 PedestrianMotionType::Running
1669 );
1670 assert_eq!(
1671 "bendingDown".parse::<PedestrianMotionType>().unwrap(),
1672 PedestrianMotionType::BendingDown
1673 );
1674 assert!("invalid".parse::<PedestrianMotionType>().is_err());
1675 }
1676
1677 #[test]
1678 fn test_pedestrian_gesture_type_display() {
1679 assert_eq!(
1680 PedestrianGestureType::PhoneCallRightHand.to_string(),
1681 "phoneCallRightHand"
1682 );
1683 assert_eq!(
1684 PedestrianGestureType::WavingLeftArm.to_string(),
1685 "wavingLeftArm"
1686 );
1687 assert_eq!(
1688 PedestrianGestureType::CoffeeRightHand.to_string(),
1689 "coffeeRightHand"
1690 );
1691 assert_eq!(
1692 PedestrianGestureType::SandwichLeftHand.to_string(),
1693 "sandwichLeftHand"
1694 );
1695 }
1696
1697 #[test]
1698 fn test_pedestrian_gesture_type_from_str() {
1699 assert_eq!(
1700 "phoneCallRightHand"
1701 .parse::<PedestrianGestureType>()
1702 .unwrap(),
1703 PedestrianGestureType::PhoneCallRightHand
1704 );
1705 assert_eq!(
1706 "wavingLeftArm".parse::<PedestrianGestureType>().unwrap(),
1707 PedestrianGestureType::WavingLeftArm
1708 );
1709 assert_eq!(
1710 "coffeeRightHand".parse::<PedestrianGestureType>().unwrap(),
1711 PedestrianGestureType::CoffeeRightHand
1712 );
1713 assert_eq!(
1714 "sandwichLeftHand".parse::<PedestrianGestureType>().unwrap(),
1715 PedestrianGestureType::SandwichLeftHand
1716 );
1717 assert!("invalid".parse::<PedestrianGestureType>().is_err());
1718 }
1719
1720 #[test]
1721 fn test_route_strategy_display() {
1722 assert_eq!(RouteStrategy::Fastest.to_string(), "fastest");
1723 assert_eq!(
1724 RouteStrategy::LeastIntersections.to_string(),
1725 "leastIntersections"
1726 );
1727 assert_eq!(RouteStrategy::Random.to_string(), "random");
1728 assert_eq!(RouteStrategy::Shortest.to_string(), "shortest");
1729 }
1730
1731 #[test]
1732 fn test_route_strategy_from_str() {
1733 assert_eq!(
1734 "fastest".parse::<RouteStrategy>().unwrap(),
1735 RouteStrategy::Fastest
1736 );
1737 assert_eq!(
1738 "leastIntersections".parse::<RouteStrategy>().unwrap(),
1739 RouteStrategy::LeastIntersections
1740 );
1741 assert_eq!(
1742 "random".parse::<RouteStrategy>().unwrap(),
1743 RouteStrategy::Random
1744 );
1745 assert_eq!(
1746 "shortest".parse::<RouteStrategy>().unwrap(),
1747 RouteStrategy::Shortest
1748 );
1749 assert!("invalid".parse::<RouteStrategy>().is_err());
1750 }
1751
1752 #[test]
1753 fn test_routing_algorithm_display() {
1754 assert_eq!(RoutingAlgorithm::AssignedRoute.to_string(), "assignedRoute");
1755 assert_eq!(RoutingAlgorithm::Fastest.to_string(), "fastest");
1756 assert_eq!(
1757 RoutingAlgorithm::LeastIntersections.to_string(),
1758 "leastIntersections"
1759 );
1760 assert_eq!(RoutingAlgorithm::Shortest.to_string(), "shortest");
1761 assert_eq!(RoutingAlgorithm::Undefined.to_string(), "undefined");
1762 }
1763
1764 #[test]
1765 fn test_routing_algorithm_from_str() {
1766 assert_eq!(
1767 "assignedRoute".parse::<RoutingAlgorithm>().unwrap(),
1768 RoutingAlgorithm::AssignedRoute
1769 );
1770 assert_eq!(
1771 "fastest".parse::<RoutingAlgorithm>().unwrap(),
1772 RoutingAlgorithm::Fastest
1773 );
1774 assert_eq!(
1775 "leastIntersections".parse::<RoutingAlgorithm>().unwrap(),
1776 RoutingAlgorithm::LeastIntersections
1777 );
1778 assert_eq!(
1779 "shortest".parse::<RoutingAlgorithm>().unwrap(),
1780 RoutingAlgorithm::Shortest
1781 );
1782 assert_eq!(
1783 "undefined".parse::<RoutingAlgorithm>().unwrap(),
1784 RoutingAlgorithm::Undefined
1785 );
1786 assert!("invalid".parse::<RoutingAlgorithm>().is_err());
1787 }
1788
1789 #[test]
1790 fn test_lateral_displacement_display() {
1791 assert_eq!(LateralDisplacement::Any.to_string(), "any");
1792 assert_eq!(
1793 LateralDisplacement::LeftToReferencedEntity.to_string(),
1794 "leftToReferencedEntity"
1795 );
1796 assert_eq!(
1797 LateralDisplacement::RightToReferencedEntity.to_string(),
1798 "rightToReferencedEntity"
1799 );
1800 }
1801
1802 #[test]
1803 fn test_lateral_displacement_from_str() {
1804 assert_eq!(
1805 "any".parse::<LateralDisplacement>().unwrap(),
1806 LateralDisplacement::Any
1807 );
1808 assert_eq!(
1809 "leftToReferencedEntity"
1810 .parse::<LateralDisplacement>()
1811 .unwrap(),
1812 LateralDisplacement::LeftToReferencedEntity
1813 );
1814 assert_eq!(
1815 "rightToReferencedEntity"
1816 .parse::<LateralDisplacement>()
1817 .unwrap(),
1818 LateralDisplacement::RightToReferencedEntity
1819 );
1820 assert!("invalid".parse::<LateralDisplacement>().is_err());
1821 }
1822
1823 #[test]
1824 fn test_longitudinal_displacement_display() {
1825 assert_eq!(LongitudinalDisplacement::Any.to_string(), "any");
1826 assert_eq!(
1827 LongitudinalDisplacement::TrailingReferencedEntity.to_string(),
1828 "trailingReferencedEntity"
1829 );
1830 assert_eq!(
1831 LongitudinalDisplacement::LeadingReferencedEntity.to_string(),
1832 "leadingReferencedEntity"
1833 );
1834 }
1835
1836 #[test]
1837 fn test_longitudinal_displacement_from_str() {
1838 assert_eq!(
1839 "any".parse::<LongitudinalDisplacement>().unwrap(),
1840 LongitudinalDisplacement::Any
1841 );
1842 assert_eq!(
1843 "trailingReferencedEntity"
1844 .parse::<LongitudinalDisplacement>()
1845 .unwrap(),
1846 LongitudinalDisplacement::TrailingReferencedEntity
1847 );
1848 assert_eq!(
1849 "leadingReferencedEntity"
1850 .parse::<LongitudinalDisplacement>()
1851 .unwrap(),
1852 LongitudinalDisplacement::LeadingReferencedEntity
1853 );
1854 assert!("invalid".parse::<LongitudinalDisplacement>().is_err());
1855 }
1856
1857 #[test]
1858 fn test_cloud_state_display() {
1859 assert_eq!(CloudState::Cloudy.to_string(), "cloudy");
1860 assert_eq!(CloudState::Free.to_string(), "free");
1861 assert_eq!(CloudState::Overcast.to_string(), "overcast");
1862 assert_eq!(CloudState::Rainy.to_string(), "rainy");
1863 assert_eq!(CloudState::SkyOff.to_string(), "skyOff");
1864 }
1865
1866 #[test]
1867 fn test_cloud_state_from_str() {
1868 assert_eq!("cloudy".parse::<CloudState>().unwrap(), CloudState::Cloudy);
1869 assert_eq!("free".parse::<CloudState>().unwrap(), CloudState::Free);
1870 assert_eq!(
1871 "overcast".parse::<CloudState>().unwrap(),
1872 CloudState::Overcast
1873 );
1874 assert_eq!("rainy".parse::<CloudState>().unwrap(), CloudState::Rainy);
1875 assert_eq!("skyOff".parse::<CloudState>().unwrap(), CloudState::SkyOff);
1876 assert!("invalid".parse::<CloudState>().is_err());
1877 }
1878
1879 #[test]
1880 fn test_cloud_state_deprecation_warning() {
1881 let _state = CloudState::Free;
1884 }
1886}