Skip to main content

maliput/api/rules/
mod.rs

1// BSD 3-Clause License
2//
3// Copyright (c) 2024, Woven by Toyota.
4// All rights reserved.
5//
6// Redistribution and use in source and binary forms, with or without
7// modification, are permitted provided that the following conditions are met:
8//
9// * Redistributions of source code must retain the above copyright notice, this
10//   list of conditions and the following disclaimer.
11//
12// * Redistributions in binary form must reproduce the above copyright notice,
13//   this list of conditions and the following disclaimer in the documentation
14//   and/or other materials provided with the distribution.
15//
16// * Neither the name of the copyright holder nor the names of its
17//   contributors may be used to endorse or promote products derived from
18//   this software without specific prior written permission.
19//
20// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31use std::collections::HashMap;
32
33use crate::{api::RoadPosition, common::MaliputError};
34use strum_macros::{Display, IntoStaticStr};
35
36/// Interface for accessing the [TrafficLight] in the [super::RoadNetwork]
37pub struct TrafficLightBook<'a> {
38    pub(super) traffic_light_book: &'a maliput_sys::api::rules::ffi::TrafficLightBook,
39}
40
41impl<'a> TrafficLightBook<'a> {
42    /// Gets all the [TrafficLight]s in the [TrafficLightBook]
43    ///
44    /// # Returns
45    /// A vector of [TrafficLight]s
46    pub fn traffic_lights(&self) -> Vec<TrafficLight<'_>> {
47        let traffic_lights_cpp = maliput_sys::api::rules::ffi::TrafficLightBook_TrafficLights(self.traffic_light_book);
48        traffic_lights_cpp
49            .into_iter()
50            .map(|tl| TrafficLight {
51                traffic_light: unsafe { tl.traffic_light.as_ref().expect("") },
52            })
53            .collect::<Vec<TrafficLight>>()
54    }
55
56    /// Gets a [TrafficLight] by its id.
57    ///
58    /// # Arguments
59    /// * `id` - The id of the [TrafficLight].
60    ///
61    /// # Returns
62    /// The [TrafficLight] with the given id.
63    /// If no [TrafficLight] is found with the given id, return None.
64    pub fn get_traffic_light(&self, id: &String) -> Option<TrafficLight<'_>> {
65        let traffic_light = maliput_sys::api::rules::ffi::TrafficLightBook_GetTrafficLight(self.traffic_light_book, id);
66        if traffic_light.is_null() {
67            return None;
68        }
69        Some(TrafficLight {
70            traffic_light: unsafe {
71                traffic_light
72                    .as_ref()
73                    .expect("Unable to get underlying traffic light pointer")
74            },
75        })
76    }
77
78    /// Gets all [TrafficLight]s whose `related_lanes()` includes the given lane ID.
79    ///
80    /// # Arguments
81    /// * `lane_id` - The lane ID to look up.
82    ///
83    /// # Returns
84    /// A vector of [TrafficLight]s associated with the given lane.
85    /// Returns an empty vector if no traffic lights are associated with the lane.
86    pub fn find_by_lane(&self, lane_id: &String) -> Vec<TrafficLight<'_>> {
87        let traffic_lights_cpp =
88            maliput_sys::api::rules::ffi::TrafficLightBook_FindByLane(self.traffic_light_book, lane_id);
89        traffic_lights_cpp
90            .into_iter()
91            .map(|tl| TrafficLight {
92                traffic_light: unsafe { tl.traffic_light.as_ref().expect("TrafficLight pointer is null") },
93            })
94            .collect::<Vec<TrafficLight>>()
95    }
96}
97
98/// Models a traffic light. A traffic light is a physical signaling device
99/// typically located at road intersections. It contains one or more groups of
100/// light bulbs with varying colors and shapes. The lighting patterns of the
101/// bulbs signify right-of-way rule information to the agents navigating the
102/// intersection (e.g., vehicles, bicyclists, pedestrians, etc.). Typically, an
103/// intersection will be managed by multiple traffic lights.
104///
105/// Note that traffic lights are physical manifestations of underlying
106/// right-of-way rules and thus naturally have lower signal-to-noise ratio
107/// relative to the underlying rules. Thus, oracular agents should directly use
108/// the underlying right-of-way rules instead of traffic lights when navigating
109/// intersections. TrafficLight exists for testing autonomous vehicles that do
110/// not have access to right-of-way rules.
111pub struct TrafficLight<'a> {
112    pub traffic_light: &'a maliput_sys::api::rules::ffi::TrafficLight,
113}
114
115impl<'a> TrafficLight<'a> {
116    /// Get the id of the [TrafficLight].
117    ///
118    /// # Returns
119    /// The id of the [TrafficLight].
120    pub fn id(&self) -> String {
121        maliput_sys::api::rules::ffi::TrafficLight_id(self.traffic_light)
122    }
123
124    /// Get the position of the [TrafficLight] in the road network.
125    ///
126    /// # Returns
127    /// An [super::InertialPosition] representing the position of the [TrafficLight] in the road network.
128    pub fn position_road_network(&self) -> super::InertialPosition {
129        let inertial_position = maliput_sys::api::rules::ffi::TrafficLight_position_road_network(self.traffic_light);
130        super::InertialPosition { ip: inertial_position }
131    }
132
133    /// Get the orientation of the [TrafficLight] in the road network.
134    ///
135    /// # Returns
136    /// An [super::Rotation] representing the orientation of the [TrafficLight] in the road network.
137    pub fn orientation_road_network(&self) -> super::Rotation {
138        let rotation = maliput_sys::api::rules::ffi::TrafficLight_orientation_road_network(self.traffic_light);
139        super::Rotation { r: rotation }
140    }
141
142    /// Get the bulb groups of the [TrafficLight].
143    ///
144    /// # Returns
145    /// A vector of [BulbGroup]s in the [TrafficLight].
146    /// If the [TrafficLight] has no bulb groups, return an empty vector.
147    pub fn bulb_groups(&self) -> Vec<BulbGroup<'_>> {
148        let bulb_groups_cpp = maliput_sys::api::rules::ffi::TrafficLight_bulb_groups(self.traffic_light);
149        bulb_groups_cpp
150            .into_iter()
151            .map(|bg| BulbGroup {
152                bulb_group: unsafe { bg.bulb_group.as_ref().expect("") },
153            })
154            .collect::<Vec<BulbGroup>>()
155    }
156
157    /// Get a [BulbGroup] by its id.
158    ///
159    /// # Arguments
160    /// * `id` - The id of the [BulbGroup].
161    ///
162    /// # Returns
163    /// The [BulbGroup] with the given id.
164    /// If no [BulbGroup] is found with the given id, return None.
165    pub fn get_bulb_group(&self, id: &String) -> Option<BulbGroup<'_>> {
166        let bulb_group = maliput_sys::api::rules::ffi::TrafficLight_GetBulbGroup(self.traffic_light, id);
167        if bulb_group.is_null() {
168            return None;
169        }
170        Some(BulbGroup {
171            bulb_group: unsafe {
172                bulb_group
173                    .as_ref()
174                    .expect("Unable to get underlying bulb group pointer")
175            },
176        })
177    }
178
179    /// Get the lane IDs that this traffic light is physically relevant to.
180    ///
181    /// # Returns
182    /// A vector of lane ID strings.
183    pub fn related_lanes(&self) -> Vec<String> {
184        maliput_sys::api::rules::ffi::TrafficLight_related_lanes(self.traffic_light)
185    }
186}
187
188#[derive(Debug, Copy, Clone, PartialEq, Eq)]
189/// Defines the possible bulb colors.
190pub enum BulbColor {
191    Red,
192    Yellow,
193    Green,
194}
195
196#[derive(Debug, Copy, Clone, PartialEq, Eq)]
197/// Defines the possible bulb types.
198pub enum BulbType {
199    Round,
200    /// Arrow with a custom orientation specified by [Bulb::arrow_orientation_rad].
201    Arrow,
202    /// Predefined arrow pointing left.
203    ArrowLeft,
204    /// Predefined arrow pointing right.
205    ArrowRight,
206    /// Predefined arrow pointing up (forward).
207    ArrowUp,
208    /// Predefined arrow pointing upper-left.
209    ArrowUpperLeft,
210    /// Predefined arrow pointing upper-right.
211    ArrowUpperRight,
212    /// U-turn to the left.
213    UTurnLeft,
214    /// U-turn to the right.
215    UTurnRight,
216    /// Pedestrian walk signal.
217    Walk,
218    /// Pedestrian don't walk signal.
219    DontWalk,
220}
221
222#[derive(Debug, Copy, Clone, PartialEq, Eq)]
223/// Defines the possible bulb states.
224pub enum BulbState {
225    Off,
226    On,
227    Blinking,
228}
229
230/// Models a bulb within a bulb group.
231pub struct Bulb<'a> {
232    pub bulb: &'a maliput_sys::api::rules::ffi::Bulb,
233}
234
235impl Bulb<'_> {
236    /// Returns this Bulb instance's unique identifier.
237    ///
238    /// # Returns
239    /// A [UniqueBulbId] representing the unique identifier of the [Bulb].
240    pub fn unique_id(&self) -> UniqueBulbId {
241        UniqueBulbId {
242            unique_bulb_id: maliput_sys::api::rules::ffi::Bulb_unique_id(self.bulb),
243        }
244    }
245
246    /// Get the id of the [Bulb].
247    ///
248    /// # Returns
249    /// The id of the [Bulb].
250    pub fn id(&self) -> String {
251        maliput_sys::api::rules::ffi::Bulb_id(self.bulb)
252    }
253
254    /// Get the color of the [Bulb].
255    ///
256    /// # Returns
257    /// The [BulbColor].
258    pub fn color(&self) -> BulbColor {
259        let color = self.bulb.color();
260        match *color {
261            maliput_sys::api::rules::ffi::BulbColor::kRed => BulbColor::Red,
262            maliput_sys::api::rules::ffi::BulbColor::kYellow => BulbColor::Yellow,
263            maliput_sys::api::rules::ffi::BulbColor::kGreen => BulbColor::Green,
264            _ => panic!("Invalid bulb color"),
265        }
266    }
267
268    /// Get the type of the [Bulb].
269    ///
270    /// # Returns
271    /// The [BulbType].
272    pub fn bulb_type(&self) -> BulbType {
273        let bulb_type = maliput_sys::api::rules::ffi::Bulb_type(self.bulb);
274        match *bulb_type {
275            maliput_sys::api::rules::ffi::BulbType::kRound => BulbType::Round,
276            maliput_sys::api::rules::ffi::BulbType::kArrow => BulbType::Arrow,
277            maliput_sys::api::rules::ffi::BulbType::kArrowLeft => BulbType::ArrowLeft,
278            maliput_sys::api::rules::ffi::BulbType::kArrowRight => BulbType::ArrowRight,
279            maliput_sys::api::rules::ffi::BulbType::kArrowUp => BulbType::ArrowUp,
280            maliput_sys::api::rules::ffi::BulbType::kArrowUpperLeft => BulbType::ArrowUpperLeft,
281            maliput_sys::api::rules::ffi::BulbType::kArrowUpperRight => BulbType::ArrowUpperRight,
282            maliput_sys::api::rules::ffi::BulbType::kUTurnLeft => BulbType::UTurnLeft,
283            maliput_sys::api::rules::ffi::BulbType::kUTurnRight => BulbType::UTurnRight,
284            maliput_sys::api::rules::ffi::BulbType::kWalk => BulbType::Walk,
285            maliput_sys::api::rules::ffi::BulbType::kDontWalk => BulbType::DontWalk,
286            _ => panic!("Invalid bulb type"),
287        }
288    }
289
290    /// Get the position of the [Bulb] in the bulb group.
291    ///
292    /// # Returns
293    /// An [super::InertialPosition] representing the position of the [Bulb] in the bulb group.
294    pub fn position_bulb_group(&self) -> super::InertialPosition {
295        let inertial_position = maliput_sys::api::rules::ffi::Bulb_position_bulb_group(self.bulb);
296        super::InertialPosition { ip: inertial_position }
297    }
298
299    /// Get the orientation of the [Bulb] in the bulb group.
300    ///
301    /// # Returns
302    /// An [super::Rotation] representing the orientation of the [Bulb] in the bulb group.
303    pub fn orientation_bulb_group(&self) -> super::Rotation {
304        let rotation = maliput_sys::api::rules::ffi::Bulb_orientation_bulb_group(self.bulb);
305        super::Rotation { r: rotation }
306    }
307
308    /// Returns the arrow's orientation. Only applicable if [Bulb::bulb_type] returns [BulbType::Arrow].
309    ///
310    /// # Returns
311    /// An `Option<f64>` representing the orientation of the arrow in radians.
312    pub fn arrow_orientation_rad(&self) -> Option<f64> {
313        let arrow_orientation = maliput_sys::api::rules::ffi::Bulb_arrow_orientation_rad(self.bulb);
314        if arrow_orientation.is_null() {
315            return None;
316        }
317        Some(arrow_orientation.value)
318    }
319
320    /// Gets the possible states of the [Bulb].
321    ///
322    /// # Returns
323    /// A vector of [BulbState]s representing the possible states of the [Bulb].
324    pub fn states(&self) -> Vec<BulbState> {
325        let states_cpp = maliput_sys::api::rules::ffi::Bulb_states(self.bulb);
326        states_cpp
327            .into_iter()
328            .map(Bulb::_from_cpp_state_to_rust_state)
329            .collect::<Vec<BulbState>>()
330    }
331
332    /// Gets the default state of the [Bulb].
333    ///
334    /// # Returns
335    /// A [BulbState] representing the default state of the [Bulb].
336    pub fn get_default_state(&self) -> BulbState {
337        let default_state = self.bulb.GetDefaultState();
338        Bulb::_from_cpp_state_to_rust_state(&default_state)
339    }
340
341    /// Check if the given state is possible valid for the [Bulb].
342    ///
343    /// # Arguments
344    /// * `state` - The [BulbState] to check.
345    ///
346    /// # Returns
347    /// A boolean indicating whether the given state is valid for the [Bulb].
348    pub fn is_valid_state(&self, state: &BulbState) -> bool {
349        self.bulb.IsValidState(&Bulb::_from_rust_state_to_cpp_state(state))
350    }
351
352    /// Returns the bounding box of the bulb.
353    ///
354    /// # Returns
355    /// A tuple containing the minimum and maximum points of the bounding box.
356    pub fn bounding_box(&self) -> (crate::math::Vector3, crate::math::Vector3) {
357        let min = maliput_sys::api::rules::ffi::Bulb_bounding_box_min(self.bulb);
358        let max = maliput_sys::api::rules::ffi::Bulb_bounding_box_max(self.bulb);
359        (crate::math::Vector3 { v: min }, crate::math::Vector3 { v: max })
360    }
361
362    /// Returns the parent [BulbGroup] of the bulb.
363    ///
364    /// # Returns
365    /// The parent [BulbGroup] of the bulb.
366    /// If the bulb is not part of any group, return None.
367    pub fn bulb_group(&self) -> BulbGroup<'_> {
368        BulbGroup {
369            bulb_group: unsafe {
370                maliput_sys::api::rules::ffi::Bulb_bulb_group(self.bulb)
371                    .as_ref()
372                    .expect("Unable to get underlying bulb group pointer. The Bulb might not be part of any BulbGroup.")
373            },
374        }
375    }
376
377    /// Convert from the C++ BulbState to the Rust BulbState
378    /// It is expected to be used only internally.
379    ///
380    /// # Arguments
381    /// * `cpp_bulb_state` - The C++ BulbState
382    ///
383    /// # Returns
384    /// The Rust BulbState
385    ///
386    /// # Panics
387    /// If the C++ BulbState is invalid.
388    fn _from_cpp_state_to_rust_state(cpp_bulb_state: &maliput_sys::api::rules::ffi::BulbState) -> BulbState {
389        match *cpp_bulb_state {
390            maliput_sys::api::rules::ffi::BulbState::kOff => BulbState::Off,
391            maliput_sys::api::rules::ffi::BulbState::kOn => BulbState::On,
392            maliput_sys::api::rules::ffi::BulbState::kBlinking => BulbState::Blinking,
393            _ => panic!("Invalid bulb state"),
394        }
395    }
396
397    /// Convert from the Rust BulbState to the C++ BulbState
398    /// It is expected to be used only internally.
399    ///
400    /// # Arguments
401    /// * `rust_bulb_state` - The Rust BulbState
402    ///
403    /// # Returns
404    /// The C++ BulbState
405    fn _from_rust_state_to_cpp_state(rust_bulb_state: &BulbState) -> maliput_sys::api::rules::ffi::BulbState {
406        match rust_bulb_state {
407            BulbState::Off => maliput_sys::api::rules::ffi::BulbState::kOff,
408            BulbState::On => maliput_sys::api::rules::ffi::BulbState::kOn,
409            BulbState::Blinking => maliput_sys::api::rules::ffi::BulbState::kBlinking,
410        }
411    }
412}
413
414/// Models a group of bulbs within a traffic light. All of the bulbs within a
415/// group should share the same approximate orientation. However, this is not
416/// programmatically enforced.
417/// About the bulb group pose:
418/// - The position of the bulb group is defined as the linear offset of this bulb group's frame
419///   relative to the frame of the traffic light that contains it. The origin of
420///   this bulb group's frame should approximate the bulb group's CoM.
421/// - The orientation of the bulb group is defined as the rotational offset of this bulb
422///   group's frame relative to the frame of the traffic light that contains it.
423///   The +Z axis should align with the bulb group's "up" direction, and the +X
424///   axis should point in the direction that the bulb group is facing.
425///   Following a right-handed coordinate frame, the +Y axis should point left
426///   when facing the +X direction.
427pub struct BulbGroup<'a> {
428    pub bulb_group: &'a maliput_sys::api::rules::ffi::BulbGroup,
429}
430
431impl BulbGroup<'_> {
432    /// Returns this BulbGroup instance's unique identifier.
433    ///
434    /// # Returns
435    /// A [UniqueBulbGroupId] representing the unique identifier of the [BulbGroup].
436    pub fn unique_id(&self) -> UniqueBulbGroupId {
437        UniqueBulbGroupId {
438            unique_bulb_group_id: maliput_sys::api::rules::ffi::BulbGroup_unique_id(self.bulb_group),
439        }
440    }
441
442    /// Gets the id of the [BulbGroup].
443    ///
444    /// # Returns
445    /// The id of the [BulbGroup].
446    pub fn id(&self) -> String {
447        maliput_sys::api::rules::ffi::BulbGroup_id(self.bulb_group)
448    }
449
450    /// Gets the position of the [BulbGroup] in the traffic light.
451    ///
452    /// # Returns
453    /// An [super::InertialPosition] representing the position of the [BulbGroup] in the traffic light.
454    pub fn position_traffic_light(&self) -> super::InertialPosition {
455        let inertial_position = maliput_sys::api::rules::ffi::BulbGroup_position_traffic_light(self.bulb_group);
456        super::InertialPosition { ip: inertial_position }
457    }
458
459    /// Gets the orientation of the [BulbGroup] in the traffic light.
460    ///
461    /// # Returns
462    /// An [super::Rotation] representing the orientation of the [BulbGroup] in the traffic light.
463    pub fn orientation_traffic_light(&self) -> super::Rotation {
464        let rotation = maliput_sys::api::rules::ffi::BulbGroup_orientation_traffic_light(self.bulb_group);
465        super::Rotation { r: rotation }
466    }
467
468    /// Returns the bulbs in the bulb group.
469    ///
470    /// # Returns
471    /// A vector of [Bulb]s in the bulb group.
472    pub fn bulbs(&self) -> Vec<Bulb<'_>> {
473        let bulbs_cpp = maliput_sys::api::rules::ffi::BulbGroup_bulbs(self.bulb_group);
474        bulbs_cpp
475            .into_iter()
476            .map(|b| Bulb {
477                bulb: unsafe { b.bulb.as_ref().expect("") },
478            })
479            .collect::<Vec<Bulb>>()
480    }
481
482    /// Gets a [Bulb] by its id
483    ///
484    /// # Arguments
485    /// * `id` - The id of the [Bulb].
486    ///
487    /// # Returns
488    /// The [Bulb] with the given id.
489    /// If no [Bulb] is found with the given id, return None.
490    pub fn get_bulb(&self, id: &String) -> Option<Bulb<'_>> {
491        let bulb = maliput_sys::api::rules::ffi::BulbGroup_GetBulb(self.bulb_group, id);
492        if bulb.is_null() {
493            return None;
494        }
495        Some(Bulb {
496            bulb: unsafe { bulb.as_ref().expect("Unable to get underlying bulb pointer") },
497        })
498    }
499
500    /// Returns the parent [TrafficLight] of the bulb group.
501    ///
502    /// # Returns
503    /// The parent [TrafficLight] of the bulb group.
504    pub fn traffic_light(&self) -> TrafficLight<'_> {
505        TrafficLight {
506            traffic_light: unsafe {
507                maliput_sys::api::rules::ffi::BulbGroup_traffic_light(self.bulb_group)
508                    .as_ref()
509                    .expect("Unable to get underlying traffic light pointer. The BulbGroup might not be registered to a TrafficLight.")
510            },
511        }
512    }
513}
514
515/// Uniquely identifies a bulb in the `Inertial` space. This consists of the
516/// concatenation of the bulb's ID, the ID of the bulb group that contains the
517/// bulb, and the the ID of the traffic light that contains the bulb group.
518///
519/// String representation of this ID is:
520/// "`traffic_light_id().string()`-`bulb_group_id.string()`-`bulb_id.string()`"
521pub struct UniqueBulbId {
522    pub(crate) unique_bulb_id: cxx::UniquePtr<maliput_sys::api::rules::ffi::UniqueBulbId>,
523}
524
525impl UniqueBulbId {
526    /// Get the traffic light id of the [UniqueBulbId].
527    ///
528    /// # Returns
529    /// The traffic light id of the [UniqueBulbId].
530    pub fn traffic_light_id(&self) -> String {
531        maliput_sys::api::rules::ffi::UniqueBulbId_traffic_light_id(&self.unique_bulb_id)
532    }
533
534    /// Get the bulb group id of the [UniqueBulbId].
535    ///
536    /// # Returns
537    /// The bulb group id of the [UniqueBulbId].
538    pub fn bulb_group_id(&self) -> String {
539        maliput_sys::api::rules::ffi::UniqueBulbId_bulb_group_id(&self.unique_bulb_id)
540    }
541
542    /// Get the bulb id of the [UniqueBulbId].
543    ///
544    /// # Returns
545    /// The bulb id of the [UniqueBulbId].
546    pub fn bulb_id(&self) -> String {
547        maliput_sys::api::rules::ffi::UniqueBulbId_bulb_id(&self.unique_bulb_id)
548    }
549
550    /// Get the string representation of the [UniqueBulbId].
551    ///
552    /// # Returns
553    /// The string representation of the [UniqueBulbId].
554    pub fn string(&self) -> String {
555        self.unique_bulb_id.string().to_string()
556    }
557}
558
559/// Uniquely identifies a bulb group in the `Inertial` space. This consists of
560/// the concatenation of the ID of the bulb group, and the ID of the traffic
561/// light that contains the bulb group.
562///
563/// String representation of this ID is:
564/// "`traffic_light_id().string()`-`bulb_group_id.string()`"
565pub struct UniqueBulbGroupId {
566    unique_bulb_group_id: cxx::UniquePtr<maliput_sys::api::rules::ffi::UniqueBulbGroupId>,
567}
568
569impl UniqueBulbGroupId {
570    /// Get the traffic light id of the [UniqueBulbGroupId].
571    ///
572    /// # Returns
573    /// The traffic light id of the [UniqueBulbGroupId].
574    pub fn traffic_light_id(&self) -> String {
575        maliput_sys::api::rules::ffi::UniqueBulbGroupId_traffic_light_id(&self.unique_bulb_group_id)
576    }
577
578    /// Get the bulb group id of the [UniqueBulbGroupId].
579    ///
580    /// # Returns
581    /// The bulb group id of the [UniqueBulbGroupId].
582    pub fn bulb_group_id(&self) -> String {
583        maliput_sys::api::rules::ffi::UniqueBulbGroupId_bulb_group_id(&self.unique_bulb_group_id)
584    }
585
586    /// Get the string representation of the [UniqueBulbGroupId].
587    ///
588    /// # Returns
589    /// The string representation of the [UniqueBulbGroupId].
590    pub fn string(&self) -> String {
591        self.unique_bulb_group_id.string().to_string()
592    }
593}
594
595/// Interface for querying types of rules. It includes both Discrete and Range value rules. It
596/// provides a registry of the various rule types.
597pub struct RuleRegistry<'a> {
598    pub(super) rule_registry: &'a maliput_sys::api::rules::ffi::RuleRegistry,
599}
600
601/// Represents the rule values the [RuleRegistry] can contain by their Discrete or Range type.
602pub enum RuleValuesByType {
603    DiscreteValues(Vec<DiscreteValue>),
604    Ranges(Vec<Range>),
605}
606
607impl<'a> RuleRegistry<'a> {
608    /// Returns all [DiscreteValue] rule type IDs.
609    ///
610    /// # Returns
611    /// A vector of [String]s representing rule type IDs that correspond to different
612    /// [DiscreteValue]s in the [RuleRegistry].
613    pub fn get_discrete_value_rule_types(&self) -> Vec<String> {
614        let discrete_value_types =
615            maliput_sys::api::rules::ffi::RuleRegistry_DiscreteValueRuleTypes(self.rule_registry);
616        let discrete_value_types = discrete_value_types
617            .as_ref()
618            .expect("Unable to get underlying discrete value rule types pointer.");
619        discrete_value_types.iter().map(|dvt| dvt.type_id.clone()).collect()
620    }
621
622    /// Returns all [DiscreteValue]s corresponding to the specified `rule_type_id`.
623    ///
624    /// This methods works in tandem with [RuleRegistry::get_discrete_value_rule_types].
625    ///
626    /// # Arguments
627    /// * `rule_type_id` - The id of the rule type.
628    ///
629    /// # Returns
630    /// A vector of [DiscreteValue]s or [None] if the `rule_type_id` doesn't match any type id in
631    /// the [RuleRegistry].
632    pub fn discrete_values_by_type(&self, rule_type_id: String) -> Option<Vec<DiscreteValue>> {
633        let discrete_value_types =
634            maliput_sys::api::rules::ffi::RuleRegistry_DiscreteValueRuleTypes(self.rule_registry);
635        let discrete_value_types = discrete_value_types
636            .as_ref()
637            .expect("Unable to get underlying discrete value rule types pointer.");
638        discrete_value_types
639            .iter()
640            .find(|dvt| dvt.type_id == rule_type_id)
641            .map(|dvt| discrete_values_from_cxx(&dvt.values))
642    }
643
644    /// Returns all [Range] rule type IDs.
645    ///
646    /// # Returns
647    /// A vector of [String]s representing rule type IDs that correspond to different [Range]s in
648    /// the [RuleRegistry].
649    pub fn get_range_rule_types(&self) -> Vec<String> {
650        let range_value_types = maliput_sys::api::rules::ffi::RuleRegistry_RangeValueRuleTypes(self.rule_registry);
651        let range_value_types = range_value_types
652            .as_ref()
653            .expect("Unable to get underlying range rule types pointer.");
654        range_value_types.iter().map(|rvt| rvt.type_id.clone()).collect()
655    }
656
657    /// Returns all [Range]s corresponding to the specified `rule_type_id`.
658    ///
659    /// This methods works in tandem with [RuleRegistry::get_range_rule_types].
660    ///
661    /// # Arguments
662    /// * `rule_type_id` - The id of the rule type.
663    ///
664    /// # Returns
665    /// A vector of [Range]s or [None] if the `rule_type_id` doesn't match any type id in the
666    /// [RuleRegistry].
667    pub fn range_values_by_type(&self, rule_type_id: String) -> Option<Vec<Range>> {
668        let range_value_types = maliput_sys::api::rules::ffi::RuleRegistry_RangeValueRuleTypes(self.rule_registry);
669        let range_value_types = range_value_types
670            .as_ref()
671            .expect("Unable to get underlying range rule types pointer.");
672        range_value_types
673            .iter()
674            .find(|rvt| rvt.type_id == rule_type_id)
675            .map(|rvt| range_values_from_cxx(&rvt.values))
676    }
677
678    /// Returns all possible states for a given `rule_type_id`.
679    ///
680    /// # Arguments
681    /// * `rule_type_id` - The id of the rule type.
682    ///
683    /// # Returns
684    /// An `Option` containing a [RuleValuesByType] enum with either a vector of [Range]s or a
685    /// vector of [DiscreteValue]s. Returns `None` if the `rule_type_id` is not found.
686    pub fn get_possible_states_of_rule_type(&self, rule_type_id: String) -> Option<RuleValuesByType> {
687        if let Some(ranges) = self.range_values_by_type(rule_type_id.clone()) {
688            Some(RuleValuesByType::Ranges(ranges))
689        } else {
690            self.discrete_values_by_type(rule_type_id)
691                .map(RuleValuesByType::DiscreteValues)
692        }
693    }
694}
695
696/// Abstraction for holding the output of [RoadRulebook::rules()] and [RoadRulebook::find_rules()]
697/// methods.
698/// This struct contains a map of [DiscreteValueRule]s and [RangeValueRule]s.
699/// The keys of the map are the ids of the rules.
700/// The values of the map are the rules.
701pub struct QueryResults {
702    pub discrete_value_rules: std::collections::HashMap<String, DiscreteValueRule>,
703    pub range_value_rules: std::collections::HashMap<String, RangeValueRule>,
704}
705
706/// Interface for querying "rules of the road". This interface
707/// provides access to static information about a road network (i.e.,
708/// information determined prior to the beginning of a simulation). Some
709/// rule types may refer to additional dynamic information which will be
710/// provided by other interfaces.
711pub struct RoadRulebook<'a> {
712    pub(super) road_rulebook: &'a maliput_sys::api::rules::ffi::RoadRulebook,
713}
714
715impl<'a> RoadRulebook<'a> {
716    /// Returns the DiscreteValueRule with the specified `id`.
717    ///
718    /// # Arguments
719    /// * `rule_id` - The id of the rule.
720    ///
721    /// # Returns
722    /// The DiscreteValueRule with the given id or None if the id is not in the Rulebook.
723    pub fn get_discrete_value_rule(&self, rule_id: &String) -> Option<DiscreteValueRule> {
724        let discrete_value_rule =
725            maliput_sys::api::rules::ffi::RoadRulebook_GetDiscreteValueRule(self.road_rulebook, rule_id);
726        if discrete_value_rule.is_null() {
727            return None;
728        }
729        Some(DiscreteValueRule { discrete_value_rule })
730    }
731    /// Returns the RangeValueRule with the specified `id`.
732    ///
733    /// # Arguments
734    /// * `rule_id` - The id of the rule.
735    ///
736    /// # Returns
737    /// The RangeValueRule with the given id or None if the id is not in the Rulebook.
738    pub fn get_range_value_rule(&self, rule_id: &String) -> Option<RangeValueRule> {
739        let range_value_rule =
740            maliput_sys::api::rules::ffi::RoadRulebook_GetRangeValueRule(self.road_rulebook, rule_id);
741        if range_value_rule.is_null() {
742            return None;
743        }
744        Some(RangeValueRule { range_value_rule })
745    }
746
747    /// Returns all the rules in the road rulebook.
748    ///
749    /// # Returns
750    /// A [QueryResults] containing all the rules in the road rulebook.
751    pub fn rules(&self) -> QueryResults {
752        let query_results_cpp = maliput_sys::api::rules::ffi::RoadRulebook_Rules(self.road_rulebook);
753        let discrete_value_rules_id =
754            maliput_sys::api::rules::ffi::QueryResults_discrete_value_rules(&query_results_cpp);
755        let range_value_rules_id = maliput_sys::api::rules::ffi::QueryResults_range_value_rules(&query_results_cpp);
756        let mut dvr_map = std::collections::HashMap::new();
757        for rule_id in discrete_value_rules_id {
758            // It is okay to unwrap here since we are iterating valid IDs obtained above.
759            let rule = self.get_discrete_value_rule(&rule_id).unwrap();
760            dvr_map.insert(rule.id(), rule);
761        }
762        let mut rvr_map = std::collections::HashMap::new();
763        for rule_id in range_value_rules_id {
764            // It is okay to unwrap here since we are iterating valid IDs obtained above.
765            let rule = self.get_range_value_rule(&rule_id).unwrap();
766            rvr_map.insert(rule.id(), rule);
767        }
768        QueryResults {
769            discrete_value_rules: dvr_map,
770            range_value_rules: rvr_map,
771        }
772    }
773
774    /// Finds rules that apply to the given lane s ranges.
775    ///
776    /// # Arguments
777    /// * `ranges` - A vector of [super::LaneSRange]s to find rules for.
778    /// * `tolerance` - A tolerance value to use when finding rules.
779    ///
780    /// # Returns
781    /// A [QueryResults] containing the rules that apply to the given lane s ranges.
782    /// If no rules are found, an empty [QueryResults] is returned.
783    ///
784    /// # Errors
785    /// Returns a [MaliputError] if the underlying C++ function fails.
786    pub fn find_rules(&self, ranges: &Vec<super::LaneSRange>, tolerance: f64) -> Result<QueryResults, MaliputError> {
787        let mut ranges_cpp = Vec::new();
788        for range in ranges {
789            ranges_cpp.push(maliput_sys::api::rules::ffi::ConstLaneSRangeRef {
790                lane_s_range: &range.lane_s_range,
791            });
792        }
793        let query_results_cpp =
794            maliput_sys::api::rules::ffi::RoadRulebook_FindRules(self.road_rulebook, &ranges_cpp, tolerance)?;
795
796        let discrete_value_rules_id =
797            maliput_sys::api::rules::ffi::QueryResults_discrete_value_rules(&query_results_cpp);
798        let range_value_rules_id = maliput_sys::api::rules::ffi::QueryResults_range_value_rules(&query_results_cpp);
799        let mut dvr_map = std::collections::HashMap::new();
800        for rule_id in discrete_value_rules_id {
801            if let Some(rule) = self.get_discrete_value_rule(&rule_id) {
802                dvr_map.insert(rule.id(), rule);
803            }
804        }
805        let mut rvr_map = std::collections::HashMap::new();
806        for rule_id in range_value_rules_id {
807            if let Some(rule) = self.get_range_value_rule(&rule_id) {
808                rvr_map.insert(rule.id(), rule);
809            }
810        }
811        Ok(QueryResults {
812            discrete_value_rules: dvr_map,
813            range_value_rules: rvr_map,
814        })
815    }
816}
817
818/// # Rule
819///
820/// A Rule may have multiple states that affect agent behavior while it is
821/// driving through the rule's zone. The possible states of a Rule must be
822/// semantically coherent. The current state of a Rule is given by a
823/// [RuleStateProvider]. States can be:
824///
825/// - range based ([RangeValueRule]).
826/// - discrete ([DiscreteValueRule]).
827///
828/// # DiscreteValueRule
829///
830/// [DiscreteValue]s are defined by a string value.
831/// Semantics of this rule are based on _all_ possible values that this
832/// [DiscreteValueRule::type_id] could have (as specified by RuleRegistry::FindRuleByType()),
833/// not only the subset of values that a specific instance of this rule can
834/// be in.
835pub struct DiscreteValueRule {
836    discrete_value_rule: cxx::UniquePtr<maliput_sys::api::rules::ffi::DiscreteValueRule>,
837}
838
839impl DiscreteValueRule {
840    /// Returns the Id of the rule as a string.
841    ///
842    /// # Returns
843    /// The id of the rule.
844    pub fn id(&self) -> String {
845        maliput_sys::api::rules::ffi::DiscreteValueRule_id(&self.discrete_value_rule)
846    }
847    /// Returns the type of the rule as a string.
848    /// Example: "right-of-way-rule-type-id", "direction-usage-rule-type-id"
849    ///
850    /// # Returns
851    /// The type id of the rule.
852    pub fn type_id(&self) -> String {
853        maliput_sys::api::rules::ffi::DiscreteValueRule_type_id(&self.discrete_value_rule)
854    }
855    /// Returns a [super::LaneSRoute] that represents the zone that the rule applies to.
856    ///
857    /// # Returns
858    /// A [super::LaneSRoute] representing the zone of the rule.
859    pub fn zone(&self) -> super::LaneSRoute {
860        let lane_s_route = maliput_sys::api::rules::ffi::DiscreteValueRule_zone(&self.discrete_value_rule);
861        super::LaneSRoute { lane_s_route }
862    }
863    /// Returns the states of the rule.
864    ///
865    /// # Returns
866    /// A vector of [DiscreteValue]s representing the states of the rule.
867    /// If the rule has no states, an empty vector is returned.
868    pub fn states(&self) -> Vec<DiscreteValue> {
869        discrete_values_from_cxx(self.discrete_value_rule.states())
870    }
871}
872
873impl std::fmt::Debug for DiscreteValueRule {
874    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
875        write!(
876            f,
877            "DiscreteValueRule {{ id: {}, type_id: {}, zone: {:?}, states: {:?} }}",
878            self.id(),
879            self.type_id(),
880            self.zone(),
881            self.states()
882        )
883    }
884}
885
886/// Holds a `Rule` ID and the current state of that `Rule`.
887/// It is usually used as a return type for [super::Intersection::discrete_value_rule_states].
888pub struct DiscreteValueRuleState {
889    /// Rule ID.
890    pub rule_id: String,
891    /// Current state of the rule.
892    pub state: DiscreteValue,
893}
894
895/// # Rule
896///
897/// A Rule may have multiple states that affect agent behavior while it is
898/// driving through the rule's zone. The possible states of a Rule must be
899/// semantically coherent. The current state of a Rule is given by a
900/// [RuleStateProvider]. States can be:
901///
902/// - range based ([RangeValueRule]).
903/// - discrete ([DiscreteValueRule]).
904///
905/// # RangeValueRule
906///
907/// [Range]s describe a numeric range based rule.
908/// Ranges are closed and continuous, defined by a minimum and maximum quantity.
909/// When only one extreme is formally defined, the other should take a
910/// semantically correct value. For example, if a speed limit only specifies a
911/// maximum value, the minimum value is typically zero.
912pub struct RangeValueRule {
913    range_value_rule: cxx::UniquePtr<maliput_sys::api::rules::ffi::RangeValueRule>,
914}
915
916impl RangeValueRule {
917    /// Returns the Id of the rule as a string.
918    ///
919    /// # Returns
920    /// The id of the rule.
921    pub fn id(&self) -> String {
922        maliput_sys::api::rules::ffi::RangeValueRule_id(&self.range_value_rule)
923    }
924    /// Returns the type of the rule as a string.
925    /// Example: "right-of-way-rule-type-id", "direction-usage-rule-type-id"
926    ///
927    /// # Returns
928    /// The type id of the rule.
929    pub fn type_id(&self) -> String {
930        maliput_sys::api::rules::ffi::RangeValueRule_type_id(&self.range_value_rule)
931    }
932    /// Returns a [super::LaneSRoute] that represents the zone that the rule applies to.
933    ///
934    /// # Returns
935    /// A [super::LaneSRoute] representing the zone of the rule.
936    pub fn zone(&self) -> super::LaneSRoute {
937        let lane_s_route = maliput_sys::api::rules::ffi::RangeValueRule_zone(&self.range_value_rule);
938        super::LaneSRoute { lane_s_route }
939    }
940    /// Returns the states of the rule.
941    ///
942    /// # Returns
943    /// A vector of [Range]s representing the states of the rule.
944    /// If the rule has no states, an empty vector is returned.
945    pub fn states(&self) -> Vec<Range> {
946        range_values_from_cxx(self.range_value_rule.states())
947    }
948}
949
950/// Defines a Rule Type.
951///
952/// # RuleType
953///
954/// [RuleType]s provide a way of obtaining a rule type's string defined in
955/// maliput's backend. Since new rule types can be created in a custom manner,
956/// [RuleType] only holds the most common types which are already defined in
957/// the backend.
958#[derive(Display, IntoStaticStr)]
959pub enum RuleType {
960    #[strum(serialize = "Direction-Usage Rule Type")]
961    DirectionUsage,
962    #[strum(serialize = "Right-Of-Way Rule Type")]
963    RightOfWay,
964    #[strum(serialize = "Vehicle-Stop-In-Zone-Behavior Rule Type")]
965    VehicleStopInZoneBehavior,
966    #[strum(serialize = "Speed-Limit Rule Type")]
967    SpeedLimit,
968}
969
970impl RuleType {
971    /// Gets the Rule ID for the [RuleType] and `lane_id`.
972    ///
973    /// # Arguments
974    /// - `lane_id` - The lane ID to get the rule ID from.
975    ///
976    /// # Returns
977    /// A rule ID formatted the way the backend defines it.
978    pub fn get_rule_id(&self, lane_id: &str) -> String {
979        // We rely on maliput_malidrive which define the rule id as:
980        // "<rule_type>/<lane_id>"
981        self.to_string() + "/" + lane_id
982    }
983}
984
985/// Defines a base state for a rule.
986///
987/// # RuleStateBase
988///
989/// - `severity` - The severity of the rule state.
990/// - `related_rules` - A map of related rules. The key is the group name and the value is a vector of rule ids.
991/// - `related_unique_ids` - A map of related unique ids. The key is the group name and the value is a vector of unique ids.
992///
993/// See [DiscreteValueRule] and [RangeValueRule] for more information.
994pub struct RuleStateBase {
995    /// Severity of the rule's state. A non-negative quantity that specifies the
996    /// level of enforcement. The smaller it is, the more strictly the rule is
997    /// enforced. Each rule type can define its own set of severity level
998    /// semantics.
999    severity: i32,
1000    related_rules: cxx::UniquePtr<cxx::CxxVector<maliput_sys::api::rules::ffi::RelatedRule>>,
1001    related_unique_ids: cxx::UniquePtr<cxx::CxxVector<maliput_sys::api::rules::ffi::RelatedUniqueId>>,
1002}
1003
1004/// A trait representing a possible state of a `Rule`.
1005///
1006/// A `Rule` can have multiple states that affect agent behavior. This trait
1007/// provides a common interface for accessing the properties shared by all
1008/// rule states, such as severity and related rules.
1009///
1010/// This trait is implemented by specific state types like [`DiscreteValue`]
1011/// and [`Range`].
1012///
1013/// # Implementors
1014///
1015/// When implementing this trait, you must provide an implementation for the
1016/// [`get_rule_state()`] method, which gives access to the underlying
1017/// [`RuleStateBase`] data. The other methods have default implementations.
1018pub trait RuleState {
1019    /// Gets the underlying [`RuleStateBase`] that contains common state properties.
1020    ///
1021    /// # Returns
1022    /// A reference to the [`RuleStateBase`] that contains the severity, related rules,
1023    /// and related unique ids for the rule state.
1024    fn get_rule_state(&self) -> &RuleStateBase;
1025
1026    /// Returns the severity of the rule state.
1027    ///
1028    /// # Returns
1029    /// An `i32` representing the severity of the rule state.
1030    /// The severity is a numeric value that indicates the importance or urgency of the rule. The lower the value, the more strictly the rule is enforced.
1031    fn severity(&self) -> i32 {
1032        self.get_rule_state().severity
1033    }
1034
1035    /// Returns a map of related rules ids. The key is the group name and the value is a vector of rule ids.
1036    ///
1037    /// # Returns
1038    /// A map of related rules where the key is the group name and the value is a vector of rule ids.
1039    fn related_rules(&self) -> std::collections::HashMap<&String, &Vec<String>> {
1040        self.get_rule_state()
1041            .related_rules
1042            .iter()
1043            .map(|rr| (&rr.group_name, &rr.rule_ids))
1044            .collect::<std::collections::HashMap<&String, &Vec<String>>>()
1045    }
1046    /// Returns a map of related unique ids. The key is the group name and the value is a vector of unique ids.
1047    ///
1048    /// # Returns
1049    /// A map of related unique ids where the key is the group name and the value is a vector of unique ids.
1050    fn related_unique_ids(&self) -> std::collections::HashMap<&String, &Vec<String>> {
1051        self.get_rule_state()
1052            .related_unique_ids
1053            .iter()
1054            .map(|rui| (&rui.group_name, &rui.unique_ids))
1055            .collect::<std::collections::HashMap<&String, &Vec<String>>>()
1056    }
1057}
1058
1059/// Defines a discrete value for a [DiscreteValueRule].
1060/// It extends the [RuleStateBase] with the value of the discrete value.
1061pub struct DiscreteValue {
1062    rule_state: RuleStateBase,
1063    value: String,
1064}
1065
1066impl RuleState for DiscreteValue {
1067    fn get_rule_state(&self) -> &RuleStateBase {
1068        &self.rule_state
1069    }
1070}
1071
1072impl DiscreteValue {
1073    /// Returns the value of the discrete value.
1074    pub fn value(&self) -> &String {
1075        &self.value
1076    }
1077}
1078
1079impl std::fmt::Debug for DiscreteValue {
1080    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1081        write!(
1082            f,
1083            "DiscreteValue {{ value: {}, severity: {}, related_rules: {:?}, related_unique_ids: {:?} }}",
1084            self.value(),
1085            self.severity(),
1086            self.related_rules(),
1087            self.related_unique_ids()
1088        )
1089    }
1090}
1091
1092/// Defines a range value for a [RangeValueRule].
1093/// It extends the [RuleStateBase] with the description, and min and max values of the range.
1094pub struct Range {
1095    rule_state: RuleStateBase,
1096    description: String,
1097    min: f64,
1098    max: f64,
1099}
1100
1101impl RuleState for Range {
1102    fn get_rule_state(&self) -> &RuleStateBase {
1103        &self.rule_state
1104    }
1105}
1106
1107impl Range {
1108    /// Returns the description of the range value.
1109    pub fn description(&self) -> &String {
1110        &self.description
1111    }
1112    /// Returns the minimum value of the range.
1113    pub fn min(&self) -> f64 {
1114        self.min
1115    }
1116    /// Returns the maximum value of the range.
1117    pub fn max(&self) -> f64 {
1118        self.max
1119    }
1120}
1121
1122/// Defines a phase in a traffic rule system.
1123///
1124/// A phase represents a specific state or configuration of traffic signals
1125/// and semantic rules within a traffic control system. Each phase has a unique
1126/// identifier and may include various traffic signal states and rule configurations
1127/// that dictate how traffic should behave during that phase.
1128pub struct Phase {
1129    phase: cxx::UniquePtr<maliput_sys::api::rules::ffi::Phase>,
1130}
1131
1132impl Phase {
1133    /// Gets the id of the [Phase].
1134    ///
1135    /// # Returns
1136    /// The id of the [Phase].
1137    pub fn id(&self) -> String {
1138        maliput_sys::api::rules::ffi::Phase_id(&self.phase)
1139    }
1140
1141    /// Gets the states of all discrete value rules for this phase.
1142    ///
1143    /// # Returns
1144    /// A `HashMap` where the key is the rule ID as a [String] and the value is the
1145    /// [DiscreteValue] state of that rule.
1146    pub fn discrete_value_rule_states(&self) -> HashMap<String, DiscreteValue> {
1147        let rule_states = maliput_sys::api::rules::ffi::Phase_discrete_value_rule_states(&self.phase);
1148        rule_states
1149            .iter()
1150            .map(|state| {
1151                (
1152                    state.rule_id.clone(),
1153                    discrete_value_from_discrete_value_cxx(&state.state),
1154                )
1155            })
1156            .collect()
1157    }
1158
1159    /// Obtains all [UniqueBulbId]s in the [Phase].
1160    ///
1161    /// # Returns
1162    /// A vector of [UniqueBulbId].
1163    pub fn unique_bulb_ids(&self) -> Vec<UniqueBulbId> {
1164        let unique_bulb_ids = maliput_sys::api::rules::ffi::Phase_unique_bulb_ids(&self.phase);
1165        unique_bulb_ids
1166            .iter()
1167            .map(|bulb_id| UniqueBulbId {
1168                unique_bulb_id: maliput_sys::api::rules::ffi::ptr_from_unique_bulb_id(bulb_id),
1169            })
1170            .collect()
1171    }
1172
1173    /// Returns the [BulbState] corresponding to a `bulb_id`.
1174    ///
1175    /// # Arguments
1176    /// * `unique_bulb_id` - The [UniqueBulbId] to get the [BulbState] from.
1177    ///
1178    /// # Returns
1179    /// The [BulbState] the `unique_bulb_id` is in, or [None] if the [UniqueBulbId] is not in this [Phase].
1180    pub fn bulb_state(&self, unique_bulb_id: &UniqueBulbId) -> Option<BulbState> {
1181        let bulb_state = maliput_sys::api::rules::ffi::Phase_bulb_state(&self.phase, &unique_bulb_id.unique_bulb_id);
1182        if bulb_state.is_null() {
1183            return None;
1184        }
1185        Some(match *bulb_state {
1186            maliput_sys::api::rules::ffi::BulbState::kOff => BulbState::Off,
1187            maliput_sys::api::rules::ffi::BulbState::kOn => BulbState::On,
1188            maliput_sys::api::rules::ffi::BulbState::kBlinking => BulbState::Blinking,
1189            _ => return None,
1190        })
1191    }
1192}
1193
1194/// Defines a phase that comes after another [Phase].
1195/// Used as a return type by:
1196///   - [PhaseRing::get_next_phases].
1197pub struct NextPhase {
1198    /// The next phase.
1199    pub next_phase: Phase,
1200    /// The default time before transitioning to the next phase. This is
1201    /// relative to when the current phase began. It is just a recommendation,
1202    /// the actual duration is determined by the PhaseProvider and may depend on
1203    /// events like a vehicle arriving at a left-turn lane or a pedestrian
1204    /// hitting a crosswalk button.
1205    pub duration_until: Option<f64>,
1206}
1207
1208/// Defines a ring of phases in a traffic rule system.
1209///
1210/// A phase ring represents a sequence of phases that a traffic control system
1211/// cycles through.
1212pub struct PhaseRing {
1213    phase_ring: cxx::UniquePtr<maliput_sys::api::rules::ffi::PhaseRing>,
1214}
1215
1216impl PhaseRing {
1217    /// Gets the id of the [PhaseRing].
1218    ///
1219    /// # Returns
1220    /// The id of the [PhaseRing].
1221    pub fn id(&self) -> String {
1222        maliput_sys::api::rules::ffi::PhaseRing_id(&self.phase_ring)
1223    }
1224
1225    /// Gets a [Phase] by its id
1226    ///
1227    /// # Arguments
1228    /// * `id` - The id of the [Phase].
1229    /// # Returns
1230    /// The [Phase] with the given id.
1231    /// If no [Phase] is found with the given id, return None.
1232    pub fn get_phase(&self, id: &String) -> Option<Phase> {
1233        let phase = maliput_sys::api::rules::ffi::PhaseRing_GetPhase(&self.phase_ring, id);
1234        if phase.is_null() {
1235            return None;
1236        }
1237        Some(Phase { phase })
1238    }
1239
1240    /// Returns the ids of all Phases in the PhaseRing.
1241    ///
1242    /// # Returns
1243    /// A vector of strings representing the ids of all Phases in the PhaseRing.
1244    pub fn phases(&self) -> Vec<String> {
1245        maliput_sys::api::rules::ffi::PhaseRing_phases_ids(&self.phase_ring)
1246    }
1247
1248    /// Returns the next phases for a given phase `id`.
1249    ///
1250    /// # Arguments
1251    /// * `id` - The id of the phase to get the next phases from.
1252    ///
1253    /// # Returns
1254    /// A `Result` containing a vector of [NextPhase]s.
1255    ///
1256    /// # Errors
1257    /// Returns a [MaliputError] if the provided `id` is not found in the [PhaseRing].
1258    pub fn get_next_phases(&self, id: &String) -> Result<Vec<NextPhase>, MaliputError> {
1259        let next_phases = maliput_sys::api::rules::ffi::PhaseRing_GetNextPhases(&self.phase_ring, id)?;
1260        Ok(next_phases
1261            .iter()
1262            .map(|np| NextPhase {
1263                next_phase: Phase {
1264                    phase: maliput_sys::api::rules::ffi::PhaseRing_GetPhase(&self.phase_ring, &np.phase_id),
1265                },
1266                duration_until: if np.duration_until.is_null() {
1267                    None
1268                } else {
1269                    Some(np.duration_until.value)
1270                },
1271            })
1272            .collect())
1273    }
1274}
1275
1276/// Defines a book of phase rings in a traffic rule system.
1277pub struct PhaseRingBook<'a> {
1278    pub(super) phase_ring_book: &'a maliput_sys::api::rules::ffi::PhaseRingBook,
1279}
1280
1281impl<'a> PhaseRingBook<'a> {
1282    /// Returns the ids of all PhaseRings in the PhaseRingBook.
1283    ///
1284    /// # Returns
1285    /// A vector of strings representing the ids of all PhaseRings in the PhaseRingBook.
1286    pub fn get_phase_rings_ids(&self) -> Vec<String> {
1287        maliput_sys::api::rules::ffi::PhaseRingBook_GetPhaseRingsId(self.phase_ring_book)
1288    }
1289
1290    /// Returns the PhaseRing with the specified `id`.
1291    ///
1292    /// # Arguments
1293    /// * `phase_ring_id` - The id of the phase ring.
1294    ///
1295    /// # Returns
1296    /// The PhaseRing with the given id or None if the id is not in the PhaseRingBook.
1297    pub fn get_phase_ring(&self, phase_ring_id: &String) -> Option<PhaseRing> {
1298        let phase_ring = maliput_sys::api::rules::ffi::PhaseRingBook_GetPhaseRing(self.phase_ring_book, phase_ring_id);
1299        if phase_ring.is_null() {
1300            return None;
1301        }
1302        Some(PhaseRing { phase_ring })
1303    }
1304
1305    /// Finds the [PhaseRing] that contains the rule with the specified `rule_id`.
1306    ///
1307    /// # Arguments
1308    /// * `rule_id` - The id of the rule.
1309    ///
1310    /// # Returns
1311    /// The [PhaseRing] that contains the rule with the given id or `None` if no [PhaseRing] is found.
1312    pub fn find_phase_ring(&self, rule_id: &String) -> Option<PhaseRing> {
1313        let phase_ring = maliput_sys::api::rules::ffi::PhaseRingBook_FindPhaseRing(self.phase_ring_book, rule_id);
1314        if phase_ring.is_null() {
1315            return None;
1316        }
1317        Some(PhaseRing { phase_ring })
1318    }
1319}
1320
1321/// Defines a next state of a generic type.
1322pub struct NextState<T> {
1323    /// The next state.
1324    pub next_state: T,
1325    /// The default time before transitioning to the next state. This is
1326    /// relative to when the current state began. It is just a recommendation,
1327    /// the actual duration is determined by the StateProvider and may depend on
1328    /// events like a vehicle arriving at a left-turn lane or a pedestrian
1329    /// hitting a crosswalk button.
1330    pub duration_until: Option<f64>,
1331}
1332
1333/// Holds the current and possible next state of a system.
1334/// It is usually returned by the different types of state providers.
1335pub struct StateProviderQuery<T> {
1336    /// The current state.
1337    pub state: T,
1338    /// The next state.
1339    pub next: Option<NextState<T>>,
1340}
1341
1342/// Alias for the [StateProviderQuery] returned by [PhaseProvider::get_phase].
1343pub type PhaseStateProviderQuery = StateProviderQuery<String>;
1344
1345/// Defines a phase provider.
1346///
1347/// A phase provider is able to get the current phase from a phase-based system.
1348pub struct PhaseProvider<'a> {
1349    pub(super) phase_provider: &'a maliput_sys::api::rules::ffi::PhaseProvider,
1350}
1351
1352impl<'a> PhaseProvider<'a> {
1353    /// Returns the [PhaseStateProviderQuery] for the specified `phase_ring_id`.
1354    ///
1355    /// The states are represented with Strings containing the IDs of each [Phase].
1356    ///
1357    /// # Arguments
1358    /// * `phase_ring_id` - The id of the phase ring.
1359    ///
1360    /// # Returns
1361    /// An `Option` containing the [PhaseStateProviderQuery] for the given `phase_ring_id`.
1362    /// Returns `None` if no phase provider is found for the given id.
1363    pub fn get_phase(&self, phase_ring_id: &String) -> Option<PhaseStateProviderQuery> {
1364        let phase_state = maliput_sys::api::rules::ffi::PhaseProvider_GetPhase(self.phase_provider, phase_ring_id);
1365        if phase_state.is_null() {
1366            return None;
1367        }
1368
1369        let next_state = maliput_sys::api::rules::ffi::PhaseStateProvider_next(&phase_state);
1370        let next_phase = if next_state.is_null() {
1371            None
1372        } else {
1373            Some(NextState {
1374                next_state: next_state.phase_id.clone(),
1375                duration_until: if next_state.duration_until.is_null() {
1376                    None
1377                } else {
1378                    Some(next_state.duration_until.value)
1379                },
1380            })
1381        };
1382
1383        Some(StateProviderQuery {
1384            state: maliput_sys::api::rules::ffi::PhaseStateProvider_state(&phase_state),
1385            next: next_phase,
1386        })
1387    }
1388}
1389
1390/// Provides the dynamic state of [DiscreteValueRule]s.
1391///
1392/// While a [RoadRulebook] provides the static definitions of rules, a
1393/// `DiscreteValueRuleStateProvider` provides the current state of those rules
1394/// at runtime. This allows for querying what state a rule is currently in,
1395/// which is essential for dynamic systems where rule states can change over
1396/// time (e.g., traffic light phases changing).
1397pub struct DiscreteValueRuleStateProvider<'a> {
1398    pub(super) state_provider: &'a maliput_sys::api::rules::ffi::DiscreteValueRuleStateProvider,
1399}
1400
1401impl<'a> DiscreteValueRuleStateProvider<'a> {
1402    /// Gets a state from the provider based on it's `rule_id`.
1403    ///
1404    /// # Arguments
1405    /// * `rule_id` - A Rule ID.
1406    ///
1407    /// # Returns
1408    /// An Option containing the [StateProviderQuery] with a [DiscreteValue] if the `rule_id` matches with any rule.
1409    /// Otherwise, None is returned.
1410    pub fn get_state_by_rule_id(&self, rule_id: &String) -> Option<StateProviderQuery<DiscreteValue>> {
1411        let query_state =
1412            maliput_sys::api::rules::ffi::DiscreteValueRuleStateProvider_GetStateById(self.state_provider, rule_id);
1413        Self::next_state_from_cxx_query(query_state)
1414    }
1415
1416    /// Gets a state from the provider if there is a `rule_type` in the received `road_position`.
1417    ///
1418    /// # Arguments
1419    /// * `road_position` - A position in the road geometry.
1420    /// * `rule_type` - A Rule Type.
1421    /// * `tolerance` - The tolerance in which to look for the Rule of type `rule_type` around the `road_position`.
1422    ///
1423    /// # Returns
1424    /// An Option containing the [StateProviderQuery] with a [DiscreteValue] if `rule_type` matches with any rule's type near `road_position`.
1425    /// Otherwise, None is returned.
1426    pub fn get_state_by_rule_type(
1427        &self,
1428        road_position: &RoadPosition,
1429        rule_type: RuleType,
1430        tolerance: f64,
1431    ) -> Option<StateProviderQuery<DiscreteValue>> {
1432        let query_state = maliput_sys::api::rules::ffi::DiscreteValueRuleStateProvider_GetStateByType(
1433            self.state_provider,
1434            &road_position.rp,
1435            &rule_type.to_string(),
1436            tolerance,
1437        );
1438        Self::next_state_from_cxx_query(query_state)
1439    }
1440
1441    // Internal helper to avoid code duplication.
1442    fn next_state_from_cxx_query(
1443        query_state: cxx::UniquePtr<maliput_sys::api::rules::ffi::DiscreteValueRuleStateProviderQuery>,
1444    ) -> Option<StateProviderQuery<DiscreteValue>> {
1445        if query_state.is_null() {
1446            return None;
1447        }
1448        let next_state = maliput_sys::api::rules::ffi::DiscreteValueRuleStateProviderQuery_next(&query_state);
1449        Some(StateProviderQuery {
1450            state: discrete_value_from_discrete_value_cxx(
1451                &maliput_sys::api::rules::ffi::DiscreteValueRuleStateProviderQuery_state(&query_state),
1452            ),
1453            next: if next_state.is_null() {
1454                None
1455            } else {
1456                Some(NextState {
1457                    next_state: discrete_value_from_discrete_value_cxx(&next_state.state),
1458                    duration_until: if next_state.duration_until.is_null() {
1459                        None
1460                    } else {
1461                        Some(next_state.duration_until.value)
1462                    },
1463                })
1464            },
1465        })
1466    }
1467}
1468
1469/// Provides the dynamic state of [RangeValueRule]s.
1470///
1471/// While a [RoadRulebook] provides the static definitions of rules, a
1472/// `RangeValueRuleStateProvider` provides the current state of those rules
1473/// at runtime. This allows for querying what state a rule is currently in,
1474/// which is essential for dynamic systems where rule states can change over
1475/// time (e.g., variable speed limits based on types of roads).
1476pub struct RangeValueRuleStateProvider<'a> {
1477    pub(super) state_provider: &'a maliput_sys::api::rules::ffi::RangeValueRuleStateProvider,
1478}
1479
1480impl<'a> RangeValueRuleStateProvider<'a> {
1481    /// Gets a state from the provider based on it's `rule_id`.
1482    ///
1483    /// # Arguments
1484    /// * `rule_id` - A Rule ID.
1485    ///
1486    /// # Returns
1487    /// An Option containing the [StateProviderQuery] with a [Range] if the `rule_id` matches with any rule.
1488    /// Otherwise, None is returned.
1489    pub fn get_state_by_rule_id(&self, rule_id: &String) -> Option<StateProviderQuery<Range>> {
1490        let query_state =
1491            maliput_sys::api::rules::ffi::RangeValueRuleStateProvider_GetStateById(self.state_provider, rule_id);
1492        Self::next_state_from_cxx_query(query_state)
1493    }
1494
1495    /// Gets a state from the provider if there is a `rule_type` in the received `road_position`.
1496    ///
1497    /// # Arguments
1498    /// * `road_position` - A position in the road geometry.
1499    /// * `rule_type` - A Rule Type.
1500    /// * `tolerance` - The tolerance in which to look for the Rule of type `rule_type` around the `road_position`.
1501    ///
1502    /// # Returns
1503    /// An Option containing the [StateProviderQuery] with a [Range] if `rule_type` matches with any rule's type near `road_position`.
1504    /// Otherwise, None is returned.
1505    pub fn get_state_by_rule_type(
1506        &self,
1507        road_position: &RoadPosition,
1508        rule_type: RuleType,
1509        tolerance: f64,
1510    ) -> Option<StateProviderQuery<Range>> {
1511        let query_state = maliput_sys::api::rules::ffi::RangeValueRuleStateProvider_GetStateByType(
1512            self.state_provider,
1513            &road_position.rp,
1514            &rule_type.to_string(),
1515            tolerance,
1516        );
1517        Self::next_state_from_cxx_query(query_state)
1518    }
1519
1520    // Internal helper to avoid code duplication.
1521    fn next_state_from_cxx_query(
1522        query_state: cxx::UniquePtr<maliput_sys::api::rules::ffi::RangeValueRuleStateProviderQuery>,
1523    ) -> Option<StateProviderQuery<Range>> {
1524        if query_state.is_null() {
1525            return None;
1526        }
1527        let next_state = maliput_sys::api::rules::ffi::RangeValueRuleStateProviderQuery_next(&query_state);
1528        Some(StateProviderQuery {
1529            state: range_value_from_range_value_cxx(
1530                &maliput_sys::api::rules::ffi::RangeValueRuleStateProviderQuery_state(&query_state),
1531            ),
1532            next: if next_state.is_null() {
1533                None
1534            } else {
1535                Some(NextState {
1536                    next_state: range_value_from_range_value_cxx(&next_state.state),
1537                    duration_until: if next_state.duration_until.is_null() {
1538                        None
1539                    } else {
1540                        Some(next_state.duration_until.value)
1541                    },
1542                })
1543            },
1544        })
1545    }
1546}
1547
1548// Auxiliary method to create a [Vec<Range>] from a [cxx::Vector<RangeValueRuleRange>].
1549fn range_values_from_cxx(
1550    range_values_cxx: &cxx::Vector<maliput_sys::api::rules::ffi::RangeValueRuleRange>,
1551) -> Vec<Range> {
1552    range_values_cxx
1553        .iter()
1554        .map(|range| Range {
1555            rule_state: RuleStateBase {
1556                severity: maliput_sys::api::rules::ffi::RangeValueRuleRange_severity(range),
1557                related_rules: maliput_sys::api::rules::ffi::RangeValueRuleRange_related_rules(range),
1558                related_unique_ids: maliput_sys::api::rules::ffi::RangeValueRuleRange_related_unique_ids(range),
1559            },
1560            description: maliput_sys::api::rules::ffi::RangeValueRuleRange_description(range),
1561            min: maliput_sys::api::rules::ffi::RangeValueRuleRange_min(range),
1562            max: maliput_sys::api::rules::ffi::RangeValueRuleRange_max(range),
1563        })
1564        .collect()
1565}
1566
1567// Auxiliary method to create a [Vec<DiscreteValue>] from a [cxx::Vector<DiscreteValueRuleDiscreteValue>].
1568fn discrete_values_from_cxx(
1569    discrete_values_cxx: &cxx::Vector<maliput_sys::api::rules::ffi::DiscreteValueRuleDiscreteValue>,
1570) -> Vec<DiscreteValue> {
1571    discrete_values_cxx
1572        .iter()
1573        .map(discrete_value_from_discrete_value_cxx)
1574        .collect()
1575}
1576
1577// Auxiliary method to create a [DiscreteValue] from a [maliput_sys::api::rules::ffi::DiscreteValueRuleDiscreteValue].
1578pub(crate) fn discrete_value_from_discrete_value_cxx(
1579    discrete_value: &maliput_sys::api::rules::ffi::DiscreteValueRuleDiscreteValue,
1580) -> DiscreteValue {
1581    DiscreteValue {
1582        rule_state: RuleStateBase {
1583            severity: maliput_sys::api::rules::ffi::DiscreteValueRuleDiscreteValue_severity(discrete_value),
1584            related_rules: maliput_sys::api::rules::ffi::DiscreteValueRuleDiscreteValue_related_rules(discrete_value),
1585            related_unique_ids: maliput_sys::api::rules::ffi::DiscreteValueRuleDiscreteValue_related_unique_ids(
1586                discrete_value,
1587            ),
1588        },
1589        value: maliput_sys::api::rules::ffi::DiscreteValueRuleDiscreteValue_value(discrete_value),
1590    }
1591}
1592
1593// Auxiliary method to create a [Range] from a [maliput_sys::api::rules::ffi::RangeValueRuleRange].
1594fn range_value_from_range_value_cxx(range: &maliput_sys::api::rules::ffi::RangeValueRuleRange) -> Range {
1595    Range {
1596        rule_state: RuleStateBase {
1597            severity: maliput_sys::api::rules::ffi::RangeValueRuleRange_severity(range),
1598            related_rules: maliput_sys::api::rules::ffi::RangeValueRuleRange_related_rules(range),
1599            related_unique_ids: maliput_sys::api::rules::ffi::RangeValueRuleRange_related_unique_ids(range),
1600        },
1601        description: maliput_sys::api::rules::ffi::RangeValueRuleRange_description(range),
1602        min: maliput_sys::api::rules::ffi::RangeValueRuleRange_min(range),
1603        max: maliput_sys::api::rules::ffi::RangeValueRuleRange_max(range),
1604    }
1605}
1606
1607#[derive(Debug, Copy, Clone, PartialEq, Eq)]
1608/// Defines the possible traffic sign types.
1609pub enum TrafficControlDeviceType {
1610    None,
1611    Other,
1612    Stop,
1613    Yield,
1614    SpeedLimit,
1615    NoEntry,
1616    OneWay,
1617    PedestrianCrossing,
1618    NoLeftTurn,
1619    NoRightTurn,
1620    NoUTurn,
1621    SchoolZone,
1622    Construction,
1623    RailroadCrossing,
1624    NoOvertaking,
1625    AllWay,
1626    NoUTurnLeft,
1627    NoUTurnRight,
1628    StopLine,
1629    Crosswalk,
1630    DangerSpot,
1631    ZebraCrossing,
1632    Flight,
1633    Cattle,
1634    HorseRiders,
1635    Amphibians,
1636    FallingRocks,
1637    SnowOrIce,
1638    LooseGravel,
1639    Waterside,
1640    Clearance,
1641    MovableBridge,
1642    RightBeforeLeftNextIntersection,
1643    TurnLeft,
1644    TurnRight,
1645    DoubleTurnLeft,
1646    DoubleTurnRight,
1647    HillDownwards,
1648    HillUpwards,
1649    UnevenRoad,
1650    RoadSlipperyWetOrDirty,
1651    SideWinds,
1652    RoadNarrowing,
1653    RoadNarrowingRight,
1654    RoadNarrowingLeft,
1655    RoadWorks,
1656    TrafficQueues,
1657    TwoWayTraffic,
1658    AttentionTrafficLight,
1659    Pedestrians,
1660    ChildrenCrossing,
1661    CycleRoute,
1662    DeerCrossing,
1663    UngatedLevelCrossing,
1664    LevelCrossingMarker,
1665    RailwayTrafficPriority,
1666    GiveWay,
1667    PriorityToOppositeDirection,
1668    PriorityToOppositeDirectionUpsideDown,
1669    PrescribedLeftTurn,
1670    PrescribedRightTurn,
1671    PrescribedStraight,
1672    PrescribedRightWay,
1673    PrescribedLeftWay,
1674    PrescribedRightTurnAndStraight,
1675    PrescribedLeftTurnAndStraight,
1676    PrescribedLeftTurnAndRightTurn,
1677    PrescribedLeftTurnRightTurnAndStraight,
1678    Roundabout,
1679    OnewayLeft,
1680    OnewayRight,
1681    PassLeft,
1682    PassRight,
1683    SideLaneOpenForTraffic,
1684    SideLaneClosedForTraffic,
1685    SideLaneClosingForTraffic,
1686    BusStop,
1687    TaxiStand,
1688    BicyclesOnly,
1689    HorseRidersOnly,
1690    PedestriansOnly,
1691    BicyclesPedestriansSharedOnly,
1692    BicyclesPedestriansSeparatedLeftOnly,
1693    BicyclesPedestriansSeparatedRightOnly,
1694    PedestrianZoneBegin,
1695    PedestrianZoneEnd,
1696    BicycleRoadBegin,
1697    BicycleRoadEnd,
1698    BusLane,
1699    BusLaneBegin,
1700    BusLaneEnd,
1701    AllProhibited,
1702    MotorizedMultitrackProhibited,
1703    TrucksProhibited,
1704    BicyclesProhibited,
1705    MotorcyclesProhibited,
1706    MopedsProhibited,
1707    HorseRidersProhibited,
1708    HorseCarriagesProhibited,
1709    CattleProhibited,
1710    BusesProhibited,
1711    CarsProhibited,
1712    CarsTrailersProhibited,
1713    TrucksTrailersProhibited,
1714    TractorsProhibited,
1715    PedestriansProhibited,
1716    MotorVehiclesProhibited,
1717    HazardousGoodsVehiclesProhibited,
1718    OverWeightVehiclesProhibited,
1719    VehiclesAxleOverWeightProhibited,
1720    VehiclesExcessWidthProhibited,
1721    VehiclesExcessHeightProhibited,
1722    VehiclesExcessLengthProhibited,
1723    DoNotEnter,
1724    SnowChainsRequired,
1725    WaterPollutantVehiclesProhibited,
1726    EnvironmentalZoneBegin,
1727    EnvironmentalZoneEnd,
1728    PrescribedUTurnLeft,
1729    PrescribedUTurnRight,
1730    MinimumDistanceForTrucks,
1731    SpeedLimitBegin,
1732    SpeedLimitZoneBegin,
1733    SpeedLimitZoneEnd,
1734    MinimumSpeedBegin,
1735    OvertakingBanBegin,
1736    OvertakingBanForTrucksBegin,
1737    SpeedLimitEnd,
1738    MinimumSpeedEnd,
1739    OvertakingBanEnd,
1740    OvertakingBanForTrucksEnd,
1741    AllRestrictionsEnd,
1742    NoStopping,
1743    NoParking,
1744    NoParkingZoneBegin,
1745    NoParkingZoneEnd,
1746    RightOfWayNextIntersection,
1747    RightOfWayBegin,
1748    RightOfWayEnd,
1749    PriorityOverOppositeDirection,
1750    PriorityOverOppositeDirectionUpsideDown,
1751    TownBegin,
1752    TownEnd,
1753    CarParking,
1754    CarParkingZoneBegin,
1755    CarParkingZoneEnd,
1756    SidewalkHalfParkingLeft,
1757    SidewalkHalfParkingRight,
1758    SidewalkParkingLeft,
1759    SidewalkParkingRight,
1760    SidewalkPerpendicularHalfParkingLeft,
1761    SidewalkPerpendicularHalfParkingRight,
1762    SidewalkPerpendicularParkingLeft,
1763    SidewalkPerpendicularParkingRight,
1764    LivingStreetBegin,
1765    LivingStreetEnd,
1766    Tunnel,
1767    EmergencyStoppingLeft,
1768    EmergencyStoppingRight,
1769    HighwayBegin,
1770    HighwayEnd,
1771    ExpresswayBegin,
1772    ExpresswayEnd,
1773    NamedHighwayExit,
1774    NamedExpresswayExit,
1775    NamedRoadExit,
1776    HighwayExit,
1777    ExpresswayExit,
1778    OnewayStreet,
1779    CrossingGuards,
1780    Deadend,
1781    DeadendExcludingDesignatedActors,
1782    FirstAidStation,
1783    PoliceStation,
1784    Telephone,
1785    FillingStation,
1786    Hotel,
1787    Inn,
1788    Kiosk,
1789    Toilet,
1790    Chapel,
1791    TouristInfo,
1792    RepairService,
1793    PedestrianUnderpass,
1794    PedestrianBridge,
1795    CamperPlace,
1796    AdvisorySpeedLimitBegin,
1797    AdvisorySpeedLimitEnd,
1798    PlaceName,
1799    TouristAttraction,
1800    TouristRoute,
1801    TouristArea,
1802    ShoulderNotPassableMotorVehicles,
1803    ShoulderUnsafeTrucksTractors,
1804    TollBegin,
1805    TollEnd,
1806    TollRoad,
1807    Customs,
1808    InternationalBorderInfo,
1809    StreetlightRedBand,
1810    FederalHighwayRouteNumber,
1811    HighwayRouteNumber,
1812    HighwayInterchangeNumber,
1813    EuropeanRouteNumber,
1814    FederalHighwayDirectionLeft,
1815    FederalHighwayDirectionRight,
1816    PrimaryRoadDirectionLeft,
1817    PrimaryRoadDirectionRight,
1818    SecondaryRoadDirectionLeft,
1819    SecondaryRoadDirectionRight,
1820    DirectionDesignatedActorsLeft,
1821    DirectionDesignatedActorsRight,
1822    RoutingDesignatedActors,
1823    DirectionToHighwayLeft,
1824    DirectionToHighwayRight,
1825    DirectionToLocalDestinationLeft,
1826    DirectionToLocalDestinationRight,
1827    ConsolidatedDirections,
1828    StreetName,
1829    DirectionPreannouncement,
1830    DirectionPreannouncementLaneConfig,
1831    DirectionPreannouncementHighwayEntries,
1832    HighwayAnnouncement,
1833    OtherRoadAnnouncement,
1834    HighwayAnnouncementTruckStop,
1835    HighwayPreannouncementDirections,
1836    PoleExit,
1837    HighwayDistanceBoard,
1838    DetourLeft,
1839    DetourRight,
1840    NumberedDetour,
1841    DetourBegin,
1842    DetourEnd,
1843    DetourRoutingBoard,
1844    OptionalDetour,
1845    OptionalDetourRouting,
1846    RouteRecommendation,
1847    RouteRecommendationEnd,
1848    AnnounceLaneTransitionLeft,
1849    AnnounceLaneTransitionRight,
1850    AnnounceRightLaneEnd,
1851    AnnounceLeftLaneEnd,
1852    AnnounceRightLaneBegin,
1853    AnnounceLeftLaneBegin,
1854    AnnounceLaneConsolidation,
1855    DetourCityBlock,
1856    Gate,
1857    PoleWarning,
1858    TrafficCone,
1859    MobileLaneClosure,
1860    ReflectorPost,
1861    DirectionalBoardWarning,
1862    GuidingPlate,
1863    GuidingPlateWedges,
1864    ParkingHazard,
1865    TrafficLightGreenArrow,
1866    Text,
1867    Space,
1868    Time,
1869    Arrow,
1870    ConstrainedTo,
1871    Except,
1872    ValidForDistance,
1873    PriorityRoadBottomLeftFourWay,
1874    PriorityRoadTopLeftFourWay,
1875    PriorityRoadBottomLeftThreeWayStraight,
1876    PriorityRoadBottomLeftThreeWaySideways,
1877    PriorityRoadTopLeftThreeWayStraight,
1878    PriorityRoadBottomRightFourWay,
1879    PriorityRoadTopRightFourWay,
1880    PriorityRoadBottomRightThreeWayStraight,
1881    PriorityRoadBottomRightThreeWaySideway,
1882    PriorityRoadTopRightThreeWayStraight,
1883    ValidInDistance,
1884    StopIn,
1885    LeftArrow,
1886    LeftBendArrow,
1887    RightArrow,
1888    RightBendArrow,
1889    Accident,
1890    Snow,
1891    Fog,
1892    RollingHighwayInformation,
1893    Services,
1894    TimeRange,
1895    ParkingDiscTimeRestriction,
1896    Weight,
1897    Wet,
1898    ParkingConstraint,
1899    NoWaitingSideStripes,
1900    Rain,
1901    SnowRain,
1902    Night,
1903    Stop4Way,
1904    Truck,
1905    TractorsMayBePassed,
1906    Hazardous,
1907    Trailer,
1908    Zone,
1909    Motorcycle,
1910    MotorcycleAllowed,
1911    Car,
1912    EmergencyLane,
1913    Unknown,
1914}
1915
1916/// Domain alias for traffic sign semantic types.
1917pub type TrafficSignType = TrafficControlDeviceType;
1918
1919#[derive(Debug, Copy, Clone, PartialEq, Eq)]
1920/// Defines the unit for a traffic sign's numeric value.
1921pub enum TrafficSignValueUnit {
1922    MetersPerSecond,
1923    KilometersPerHour,
1924    MilesPerHour,
1925    Meters,
1926    Kilometers,
1927    Feet,
1928    Miles,
1929    Percent,
1930    Kilograms,
1931    MetricTons,
1932}
1933
1934#[derive(Debug, Copy, Clone, PartialEq)]
1935/// Holds a numeric value and its associated unit for a traffic sign.
1936pub struct TrafficSignValue {
1937    pub value: f64,
1938    pub unit: TrafficSignValueUnit,
1939}
1940
1941pub(crate) fn traffic_control_device_type_from_cpp(
1942    sign_type: &maliput_sys::api::rules::ffi::TrafficControlDeviceType,
1943) -> TrafficControlDeviceType {
1944    match *sign_type {
1945        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNone => TrafficSignType::None,
1946        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kOther => TrafficSignType::Other,
1947        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kStop => TrafficSignType::Stop,
1948        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kYield => TrafficSignType::Yield,
1949        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSpeedLimit => TrafficSignType::SpeedLimit,
1950        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNoEntry => TrafficSignType::NoEntry,
1951        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kOneWay => TrafficSignType::OneWay,
1952        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPedestrianCrossing => {
1953            TrafficSignType::PedestrianCrossing
1954        }
1955        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNoLeftTurn => TrafficSignType::NoLeftTurn,
1956        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNoRightTurn => TrafficSignType::NoRightTurn,
1957        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNoUTurn => TrafficSignType::NoUTurn,
1958        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSchoolZone => TrafficSignType::SchoolZone,
1959        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kConstruction => TrafficSignType::Construction,
1960        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRailroadCrossing => TrafficSignType::RailroadCrossing,
1961        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNoOvertaking => TrafficSignType::NoOvertaking,
1962        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kAllWay => TrafficSignType::AllWay,
1963        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNoUTurnLeft => TrafficSignType::NoUTurnLeft,
1964        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNoUTurnRight => TrafficSignType::NoUTurnRight,
1965        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kStopLine => TrafficSignType::StopLine,
1966        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kCrosswalk => TrafficSignType::Crosswalk,
1967        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDangerSpot => TrafficSignType::DangerSpot,
1968        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kZebraCrossing => TrafficSignType::ZebraCrossing,
1969        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kFlight => TrafficSignType::Flight,
1970        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kCattle => TrafficSignType::Cattle,
1971        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHorseRiders => TrafficSignType::HorseRiders,
1972        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kAmphibians => TrafficSignType::Amphibians,
1973        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kFallingRocks => TrafficSignType::FallingRocks,
1974        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSnowOrIce => TrafficSignType::SnowOrIce,
1975        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kLooseGravel => TrafficSignType::LooseGravel,
1976        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kWaterside => TrafficSignType::Waterside,
1977        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kClearance => TrafficSignType::Clearance,
1978        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kMovableBridge => TrafficSignType::MovableBridge,
1979        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRightBeforeLeftNextIntersection => {
1980            TrafficSignType::RightBeforeLeftNextIntersection
1981        }
1982        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTurnLeft => TrafficSignType::TurnLeft,
1983        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTurnRight => TrafficSignType::TurnRight,
1984        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDoubleTurnLeft => TrafficSignType::DoubleTurnLeft,
1985        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDoubleTurnRight => TrafficSignType::DoubleTurnRight,
1986        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHillDownwards => TrafficSignType::HillDownwards,
1987        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHillUpwards => TrafficSignType::HillUpwards,
1988        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kUnevenRoad => TrafficSignType::UnevenRoad,
1989        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRoadSlipperyWetOrDirty => {
1990            TrafficSignType::RoadSlipperyWetOrDirty
1991        }
1992        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSideWinds => TrafficSignType::SideWinds,
1993        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRoadNarrowing => TrafficSignType::RoadNarrowing,
1994        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRoadNarrowingRight => {
1995            TrafficSignType::RoadNarrowingRight
1996        }
1997        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRoadNarrowingLeft => {
1998            TrafficSignType::RoadNarrowingLeft
1999        }
2000        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRoadWorks => TrafficSignType::RoadWorks,
2001        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTrafficQueues => TrafficSignType::TrafficQueues,
2002        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTwoWayTraffic => TrafficSignType::TwoWayTraffic,
2003        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kAttentionTrafficLight => {
2004            TrafficSignType::AttentionTrafficLight
2005        }
2006        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPedestrians => TrafficSignType::Pedestrians,
2007        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kChildrenCrossing => TrafficSignType::ChildrenCrossing,
2008        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kCycleRoute => TrafficSignType::CycleRoute,
2009        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDeerCrossing => TrafficSignType::DeerCrossing,
2010        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kUngatedLevelCrossing => {
2011            TrafficSignType::UngatedLevelCrossing
2012        }
2013        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kLevelCrossingMarker => {
2014            TrafficSignType::LevelCrossingMarker
2015        }
2016        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRailwayTrafficPriority => {
2017            TrafficSignType::RailwayTrafficPriority
2018        }
2019        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kGiveWay => TrafficSignType::GiveWay,
2020        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPriorityToOppositeDirection => {
2021            TrafficSignType::PriorityToOppositeDirection
2022        }
2023        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPriorityToOppositeDirectionUpsideDown => {
2024            TrafficSignType::PriorityToOppositeDirectionUpsideDown
2025        }
2026        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPrescribedLeftTurn => {
2027            TrafficSignType::PrescribedLeftTurn
2028        }
2029        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPrescribedRightTurn => {
2030            TrafficSignType::PrescribedRightTurn
2031        }
2032        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPrescribedStraight => {
2033            TrafficSignType::PrescribedStraight
2034        }
2035        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPrescribedRightWay => {
2036            TrafficSignType::PrescribedRightWay
2037        }
2038        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPrescribedLeftWay => {
2039            TrafficSignType::PrescribedLeftWay
2040        }
2041        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPrescribedRightTurnAndStraight => {
2042            TrafficSignType::PrescribedRightTurnAndStraight
2043        }
2044        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPrescribedLeftTurnAndStraight => {
2045            TrafficSignType::PrescribedLeftTurnAndStraight
2046        }
2047        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPrescribedLeftTurnAndRightTurn => {
2048            TrafficSignType::PrescribedLeftTurnAndRightTurn
2049        }
2050        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPrescribedLeftTurnRightTurnAndStraight => {
2051            TrafficSignType::PrescribedLeftTurnRightTurnAndStraight
2052        }
2053        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRoundabout => TrafficSignType::Roundabout,
2054        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kOnewayLeft => TrafficSignType::OnewayLeft,
2055        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kOnewayRight => TrafficSignType::OnewayRight,
2056        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPassLeft => TrafficSignType::PassLeft,
2057        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPassRight => TrafficSignType::PassRight,
2058        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSideLaneOpenForTraffic => {
2059            TrafficSignType::SideLaneOpenForTraffic
2060        }
2061        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSideLaneClosedForTraffic => {
2062            TrafficSignType::SideLaneClosedForTraffic
2063        }
2064        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSideLaneClosingForTraffic => {
2065            TrafficSignType::SideLaneClosingForTraffic
2066        }
2067        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kBusStop => TrafficSignType::BusStop,
2068        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTaxiStand => TrafficSignType::TaxiStand,
2069        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kBicyclesOnly => TrafficSignType::BicyclesOnly,
2070        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHorseRidersOnly => TrafficSignType::HorseRidersOnly,
2071        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPedestriansOnly => TrafficSignType::PedestriansOnly,
2072        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kBicyclesPedestriansSharedOnly => {
2073            TrafficSignType::BicyclesPedestriansSharedOnly
2074        }
2075        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kBicyclesPedestriansSeparatedLeftOnly => {
2076            TrafficSignType::BicyclesPedestriansSeparatedLeftOnly
2077        }
2078        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kBicyclesPedestriansSeparatedRightOnly => {
2079            TrafficSignType::BicyclesPedestriansSeparatedRightOnly
2080        }
2081        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPedestrianZoneBegin => {
2082            TrafficSignType::PedestrianZoneBegin
2083        }
2084        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPedestrianZoneEnd => {
2085            TrafficSignType::PedestrianZoneEnd
2086        }
2087        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kBicycleRoadBegin => TrafficSignType::BicycleRoadBegin,
2088        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kBicycleRoadEnd => TrafficSignType::BicycleRoadEnd,
2089        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kBusLane => TrafficSignType::BusLane,
2090        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kBusLaneBegin => TrafficSignType::BusLaneBegin,
2091        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kBusLaneEnd => TrafficSignType::BusLaneEnd,
2092        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kAllProhibited => TrafficSignType::AllProhibited,
2093        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kMotorizedMultitrackProhibited => {
2094            TrafficSignType::MotorizedMultitrackProhibited
2095        }
2096        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTrucksProhibited => TrafficSignType::TrucksProhibited,
2097        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kBicyclesProhibited => {
2098            TrafficSignType::BicyclesProhibited
2099        }
2100        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kMotorcyclesProhibited => {
2101            TrafficSignType::MotorcyclesProhibited
2102        }
2103        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kMopedsProhibited => TrafficSignType::MopedsProhibited,
2104        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHorseRidersProhibited => {
2105            TrafficSignType::HorseRidersProhibited
2106        }
2107        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHorseCarriagesProhibited => {
2108            TrafficSignType::HorseCarriagesProhibited
2109        }
2110        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kCattleProhibited => TrafficSignType::CattleProhibited,
2111        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kBusesProhibited => TrafficSignType::BusesProhibited,
2112        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kCarsProhibited => TrafficSignType::CarsProhibited,
2113        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kCarsTrailersProhibited => {
2114            TrafficSignType::CarsTrailersProhibited
2115        }
2116        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTrucksTrailersProhibited => {
2117            TrafficSignType::TrucksTrailersProhibited
2118        }
2119        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTractorsProhibited => {
2120            TrafficSignType::TractorsProhibited
2121        }
2122        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPedestriansProhibited => {
2123            TrafficSignType::PedestriansProhibited
2124        }
2125        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kMotorVehiclesProhibited => {
2126            TrafficSignType::MotorVehiclesProhibited
2127        }
2128        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHazardousGoodsVehiclesProhibited => {
2129            TrafficSignType::HazardousGoodsVehiclesProhibited
2130        }
2131        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kOverWeightVehiclesProhibited => {
2132            TrafficSignType::OverWeightVehiclesProhibited
2133        }
2134        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kVehiclesAxleOverWeightProhibited => {
2135            TrafficSignType::VehiclesAxleOverWeightProhibited
2136        }
2137        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kVehiclesExcessWidthProhibited => {
2138            TrafficSignType::VehiclesExcessWidthProhibited
2139        }
2140        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kVehiclesExcessHeightProhibited => {
2141            TrafficSignType::VehiclesExcessHeightProhibited
2142        }
2143        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kVehiclesExcessLengthProhibited => {
2144            TrafficSignType::VehiclesExcessLengthProhibited
2145        }
2146        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDoNotEnter => TrafficSignType::DoNotEnter,
2147        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSnowChainsRequired => {
2148            TrafficSignType::SnowChainsRequired
2149        }
2150        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kWaterPollutantVehiclesProhibited => {
2151            TrafficSignType::WaterPollutantVehiclesProhibited
2152        }
2153        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kEnvironmentalZoneBegin => {
2154            TrafficSignType::EnvironmentalZoneBegin
2155        }
2156        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kEnvironmentalZoneEnd => {
2157            TrafficSignType::EnvironmentalZoneEnd
2158        }
2159        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPrescribedUTurnLeft => {
2160            TrafficSignType::PrescribedUTurnLeft
2161        }
2162        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPrescribedUTurnRight => {
2163            TrafficSignType::PrescribedUTurnRight
2164        }
2165        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kMinimumDistanceForTrucks => {
2166            TrafficSignType::MinimumDistanceForTrucks
2167        }
2168        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSpeedLimitBegin => TrafficSignType::SpeedLimitBegin,
2169        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSpeedLimitZoneBegin => {
2170            TrafficSignType::SpeedLimitZoneBegin
2171        }
2172        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSpeedLimitZoneEnd => {
2173            TrafficSignType::SpeedLimitZoneEnd
2174        }
2175        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kMinimumSpeedBegin => {
2176            TrafficSignType::MinimumSpeedBegin
2177        }
2178        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kOvertakingBanBegin => {
2179            TrafficSignType::OvertakingBanBegin
2180        }
2181        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kOvertakingBanForTrucksBegin => {
2182            TrafficSignType::OvertakingBanForTrucksBegin
2183        }
2184        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSpeedLimitEnd => TrafficSignType::SpeedLimitEnd,
2185        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kMinimumSpeedEnd => TrafficSignType::MinimumSpeedEnd,
2186        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kOvertakingBanEnd => TrafficSignType::OvertakingBanEnd,
2187        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kOvertakingBanForTrucksEnd => {
2188            TrafficSignType::OvertakingBanForTrucksEnd
2189        }
2190        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kAllRestrictionsEnd => {
2191            TrafficSignType::AllRestrictionsEnd
2192        }
2193        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNoStopping => TrafficSignType::NoStopping,
2194        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNoParking => TrafficSignType::NoParking,
2195        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNoParkingZoneBegin => {
2196            TrafficSignType::NoParkingZoneBegin
2197        }
2198        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNoParkingZoneEnd => TrafficSignType::NoParkingZoneEnd,
2199        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRightOfWayNextIntersection => {
2200            TrafficSignType::RightOfWayNextIntersection
2201        }
2202        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRightOfWayBegin => TrafficSignType::RightOfWayBegin,
2203        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRightOfWayEnd => TrafficSignType::RightOfWayEnd,
2204        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPriorityOverOppositeDirection => {
2205            TrafficSignType::PriorityOverOppositeDirection
2206        }
2207        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPriorityOverOppositeDirectionUpsideDown => {
2208            TrafficSignType::PriorityOverOppositeDirectionUpsideDown
2209        }
2210        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTownBegin => TrafficSignType::TownBegin,
2211        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTownEnd => TrafficSignType::TownEnd,
2212        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kCarParking => TrafficSignType::CarParking,
2213        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kCarParkingZoneBegin => {
2214            TrafficSignType::CarParkingZoneBegin
2215        }
2216        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kCarParkingZoneEnd => {
2217            TrafficSignType::CarParkingZoneEnd
2218        }
2219        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSidewalkHalfParkingLeft => {
2220            TrafficSignType::SidewalkHalfParkingLeft
2221        }
2222        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSidewalkHalfParkingRight => {
2223            TrafficSignType::SidewalkHalfParkingRight
2224        }
2225        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSidewalkParkingLeft => {
2226            TrafficSignType::SidewalkParkingLeft
2227        }
2228        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSidewalkParkingRight => {
2229            TrafficSignType::SidewalkParkingRight
2230        }
2231        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSidewalkPerpendicularHalfParkingLeft => {
2232            TrafficSignType::SidewalkPerpendicularHalfParkingLeft
2233        }
2234        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSidewalkPerpendicularHalfParkingRight => {
2235            TrafficSignType::SidewalkPerpendicularHalfParkingRight
2236        }
2237        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSidewalkPerpendicularParkingLeft => {
2238            TrafficSignType::SidewalkPerpendicularParkingLeft
2239        }
2240        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSidewalkPerpendicularParkingRight => {
2241            TrafficSignType::SidewalkPerpendicularParkingRight
2242        }
2243        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kLivingStreetBegin => {
2244            TrafficSignType::LivingStreetBegin
2245        }
2246        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kLivingStreetEnd => TrafficSignType::LivingStreetEnd,
2247        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTunnel => TrafficSignType::Tunnel,
2248        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kEmergencyStoppingLeft => {
2249            TrafficSignType::EmergencyStoppingLeft
2250        }
2251        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kEmergencyStoppingRight => {
2252            TrafficSignType::EmergencyStoppingRight
2253        }
2254        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHighwayBegin => TrafficSignType::HighwayBegin,
2255        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHighwayEnd => TrafficSignType::HighwayEnd,
2256        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kExpresswayBegin => TrafficSignType::ExpresswayBegin,
2257        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kExpresswayEnd => TrafficSignType::ExpresswayEnd,
2258        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNamedHighwayExit => TrafficSignType::NamedHighwayExit,
2259        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNamedExpresswayExit => {
2260            TrafficSignType::NamedExpresswayExit
2261        }
2262        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNamedRoadExit => TrafficSignType::NamedRoadExit,
2263        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHighwayExit => TrafficSignType::HighwayExit,
2264        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kExpresswayExit => TrafficSignType::ExpresswayExit,
2265        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kOnewayStreet => TrafficSignType::OnewayStreet,
2266        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kCrossingGuards => TrafficSignType::CrossingGuards,
2267        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDeadend => TrafficSignType::Deadend,
2268        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDeadendExcludingDesignatedActors => {
2269            TrafficSignType::DeadendExcludingDesignatedActors
2270        }
2271        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kFirstAidStation => TrafficSignType::FirstAidStation,
2272        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPoliceStation => TrafficSignType::PoliceStation,
2273        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTelephone => TrafficSignType::Telephone,
2274        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kFillingStation => TrafficSignType::FillingStation,
2275        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHotel => TrafficSignType::Hotel,
2276        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kInn => TrafficSignType::Inn,
2277        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kKiosk => TrafficSignType::Kiosk,
2278        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kToilet => TrafficSignType::Toilet,
2279        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kChapel => TrafficSignType::Chapel,
2280        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTouristInfo => TrafficSignType::TouristInfo,
2281        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRepairService => TrafficSignType::RepairService,
2282        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPedestrianUnderpass => {
2283            TrafficSignType::PedestrianUnderpass
2284        }
2285        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPedestrianBridge => TrafficSignType::PedestrianBridge,
2286        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kCamperPlace => TrafficSignType::CamperPlace,
2287        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kAdvisorySpeedLimitBegin => {
2288            TrafficSignType::AdvisorySpeedLimitBegin
2289        }
2290        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kAdvisorySpeedLimitEnd => {
2291            TrafficSignType::AdvisorySpeedLimitEnd
2292        }
2293        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPlaceName => TrafficSignType::PlaceName,
2294        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTouristAttraction => {
2295            TrafficSignType::TouristAttraction
2296        }
2297        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTouristRoute => TrafficSignType::TouristRoute,
2298        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTouristArea => TrafficSignType::TouristArea,
2299        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kShoulderNotPassableMotorVehicles => {
2300            TrafficSignType::ShoulderNotPassableMotorVehicles
2301        }
2302        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kShoulderUnsafeTrucksTractors => {
2303            TrafficSignType::ShoulderUnsafeTrucksTractors
2304        }
2305        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTollBegin => TrafficSignType::TollBegin,
2306        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTollEnd => TrafficSignType::TollEnd,
2307        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTollRoad => TrafficSignType::TollRoad,
2308        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kCustoms => TrafficSignType::Customs,
2309        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kInternationalBorderInfo => {
2310            TrafficSignType::InternationalBorderInfo
2311        }
2312        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kStreetlightRedBand => {
2313            TrafficSignType::StreetlightRedBand
2314        }
2315        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kFederalHighwayRouteNumber => {
2316            TrafficSignType::FederalHighwayRouteNumber
2317        }
2318        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHighwayRouteNumber => {
2319            TrafficSignType::HighwayRouteNumber
2320        }
2321        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHighwayInterchangeNumber => {
2322            TrafficSignType::HighwayInterchangeNumber
2323        }
2324        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kEuropeanRouteNumber => {
2325            TrafficSignType::EuropeanRouteNumber
2326        }
2327        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kFederalHighwayDirectionLeft => {
2328            TrafficSignType::FederalHighwayDirectionLeft
2329        }
2330        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kFederalHighwayDirectionRight => {
2331            TrafficSignType::FederalHighwayDirectionRight
2332        }
2333        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPrimaryRoadDirectionLeft => {
2334            TrafficSignType::PrimaryRoadDirectionLeft
2335        }
2336        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPrimaryRoadDirectionRight => {
2337            TrafficSignType::PrimaryRoadDirectionRight
2338        }
2339        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSecondaryRoadDirectionLeft => {
2340            TrafficSignType::SecondaryRoadDirectionLeft
2341        }
2342        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSecondaryRoadDirectionRight => {
2343            TrafficSignType::SecondaryRoadDirectionRight
2344        }
2345        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDirectionDesignatedActorsLeft => {
2346            TrafficSignType::DirectionDesignatedActorsLeft
2347        }
2348        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDirectionDesignatedActorsRight => {
2349            TrafficSignType::DirectionDesignatedActorsRight
2350        }
2351        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRoutingDesignatedActors => {
2352            TrafficSignType::RoutingDesignatedActors
2353        }
2354        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDirectionToHighwayLeft => {
2355            TrafficSignType::DirectionToHighwayLeft
2356        }
2357        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDirectionToHighwayRight => {
2358            TrafficSignType::DirectionToHighwayRight
2359        }
2360        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDirectionToLocalDestinationLeft => {
2361            TrafficSignType::DirectionToLocalDestinationLeft
2362        }
2363        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDirectionToLocalDestinationRight => {
2364            TrafficSignType::DirectionToLocalDestinationRight
2365        }
2366        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kConsolidatedDirections => {
2367            TrafficSignType::ConsolidatedDirections
2368        }
2369        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kStreetName => TrafficSignType::StreetName,
2370        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDirectionPreannouncement => {
2371            TrafficSignType::DirectionPreannouncement
2372        }
2373        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDirectionPreannouncementLaneConfig => {
2374            TrafficSignType::DirectionPreannouncementLaneConfig
2375        }
2376        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDirectionPreannouncementHighwayEntries => {
2377            TrafficSignType::DirectionPreannouncementHighwayEntries
2378        }
2379        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHighwayAnnouncement => {
2380            TrafficSignType::HighwayAnnouncement
2381        }
2382        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kOtherRoadAnnouncement => {
2383            TrafficSignType::OtherRoadAnnouncement
2384        }
2385        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHighwayAnnouncementTruckStop => {
2386            TrafficSignType::HighwayAnnouncementTruckStop
2387        }
2388        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHighwayPreannouncementDirections => {
2389            TrafficSignType::HighwayPreannouncementDirections
2390        }
2391        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPoleExit => TrafficSignType::PoleExit,
2392        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHighwayDistanceBoard => {
2393            TrafficSignType::HighwayDistanceBoard
2394        }
2395        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDetourLeft => TrafficSignType::DetourLeft,
2396        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDetourRight => TrafficSignType::DetourRight,
2397        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNumberedDetour => TrafficSignType::NumberedDetour,
2398        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDetourBegin => TrafficSignType::DetourBegin,
2399        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDetourEnd => TrafficSignType::DetourEnd,
2400        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDetourRoutingBoard => {
2401            TrafficSignType::DetourRoutingBoard
2402        }
2403        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kOptionalDetour => TrafficSignType::OptionalDetour,
2404        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kOptionalDetourRouting => {
2405            TrafficSignType::OptionalDetourRouting
2406        }
2407        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRouteRecommendation => {
2408            TrafficSignType::RouteRecommendation
2409        }
2410        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRouteRecommendationEnd => {
2411            TrafficSignType::RouteRecommendationEnd
2412        }
2413        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kAnnounceLaneTransitionLeft => {
2414            TrafficSignType::AnnounceLaneTransitionLeft
2415        }
2416        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kAnnounceLaneTransitionRight => {
2417            TrafficSignType::AnnounceLaneTransitionRight
2418        }
2419        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kAnnounceRightLaneEnd => {
2420            TrafficSignType::AnnounceRightLaneEnd
2421        }
2422        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kAnnounceLeftLaneEnd => {
2423            TrafficSignType::AnnounceLeftLaneEnd
2424        }
2425        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kAnnounceRightLaneBegin => {
2426            TrafficSignType::AnnounceRightLaneBegin
2427        }
2428        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kAnnounceLeftLaneBegin => {
2429            TrafficSignType::AnnounceLeftLaneBegin
2430        }
2431        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kAnnounceLaneConsolidation => {
2432            TrafficSignType::AnnounceLaneConsolidation
2433        }
2434        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDetourCityBlock => TrafficSignType::DetourCityBlock,
2435        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kGate => TrafficSignType::Gate,
2436        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPoleWarning => TrafficSignType::PoleWarning,
2437        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTrafficCone => TrafficSignType::TrafficCone,
2438        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kMobileLaneClosure => {
2439            TrafficSignType::MobileLaneClosure
2440        }
2441        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kReflectorPost => TrafficSignType::ReflectorPost,
2442        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDirectionalBoardWarning => {
2443            TrafficSignType::DirectionalBoardWarning
2444        }
2445        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kGuidingPlate => TrafficSignType::GuidingPlate,
2446        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kGuidingPlateWedges => {
2447            TrafficSignType::GuidingPlateWedges
2448        }
2449        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kParkingHazard => TrafficSignType::ParkingHazard,
2450        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTrafficLightGreenArrow => {
2451            TrafficSignType::TrafficLightGreenArrow
2452        }
2453        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kText => TrafficSignType::Text,
2454        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSpace => TrafficSignType::Space,
2455        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTime => TrafficSignType::Time,
2456        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kArrow => TrafficSignType::Arrow,
2457        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kConstrainedTo => TrafficSignType::ConstrainedTo,
2458        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kExcept => TrafficSignType::Except,
2459        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kValidForDistance => TrafficSignType::ValidForDistance,
2460        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPriorityRoadBottomLeftFourWay => {
2461            TrafficSignType::PriorityRoadBottomLeftFourWay
2462        }
2463        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPriorityRoadTopLeftFourWay => {
2464            TrafficSignType::PriorityRoadTopLeftFourWay
2465        }
2466        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPriorityRoadBottomLeftThreeWayStraight => {
2467            TrafficSignType::PriorityRoadBottomLeftThreeWayStraight
2468        }
2469        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPriorityRoadBottomLeftThreeWaySideways => {
2470            TrafficSignType::PriorityRoadBottomLeftThreeWaySideways
2471        }
2472        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPriorityRoadTopLeftThreeWayStraight => {
2473            TrafficSignType::PriorityRoadTopLeftThreeWayStraight
2474        }
2475        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPriorityRoadBottomRightFourWay => {
2476            TrafficSignType::PriorityRoadBottomRightFourWay
2477        }
2478        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPriorityRoadTopRightFourWay => {
2479            TrafficSignType::PriorityRoadTopRightFourWay
2480        }
2481        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPriorityRoadBottomRightThreeWayStraight => {
2482            TrafficSignType::PriorityRoadBottomRightThreeWayStraight
2483        }
2484        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPriorityRoadBottomRightThreeWaySideway => {
2485            TrafficSignType::PriorityRoadBottomRightThreeWaySideway
2486        }
2487        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPriorityRoadTopRightThreeWayStraight => {
2488            TrafficSignType::PriorityRoadTopRightThreeWayStraight
2489        }
2490        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kValidInDistance => TrafficSignType::ValidInDistance,
2491        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kStopIn => TrafficSignType::StopIn,
2492        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kLeftArrow => TrafficSignType::LeftArrow,
2493        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kLeftBendArrow => TrafficSignType::LeftBendArrow,
2494        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRightArrow => TrafficSignType::RightArrow,
2495        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRightBendArrow => TrafficSignType::RightBendArrow,
2496        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kAccident => TrafficSignType::Accident,
2497        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSnow => TrafficSignType::Snow,
2498        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kFog => TrafficSignType::Fog,
2499        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRollingHighwayInformation => {
2500            TrafficSignType::RollingHighwayInformation
2501        }
2502        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kServices => TrafficSignType::Services,
2503        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTimeRange => TrafficSignType::TimeRange,
2504        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kParkingDiscTimeRestriction => {
2505            TrafficSignType::ParkingDiscTimeRestriction
2506        }
2507        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kWeight => TrafficSignType::Weight,
2508        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kWet => TrafficSignType::Wet,
2509        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kParkingConstraint => {
2510            TrafficSignType::ParkingConstraint
2511        }
2512        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNoWaitingSideStripes => {
2513            TrafficSignType::NoWaitingSideStripes
2514        }
2515        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRain => TrafficSignType::Rain,
2516        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSnowRain => TrafficSignType::SnowRain,
2517        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNight => TrafficSignType::Night,
2518        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kStop4Way => TrafficSignType::Stop4Way,
2519        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTruck => TrafficSignType::Truck,
2520        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTractorsMayBePassed => {
2521            TrafficSignType::TractorsMayBePassed
2522        }
2523        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHazardous => TrafficSignType::Hazardous,
2524        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTrailer => TrafficSignType::Trailer,
2525        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kZone => TrafficSignType::Zone,
2526        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kMotorcycle => TrafficSignType::Motorcycle,
2527        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kMotorcycleAllowed => {
2528            TrafficSignType::MotorcycleAllowed
2529        }
2530        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kCar => TrafficSignType::Car,
2531        maliput_sys::api::rules::ffi::TrafficControlDeviceType::kEmergencyLane => TrafficSignType::EmergencyLane,
2532        _ => TrafficSignType::Unknown,
2533    }
2534}
2535
2536pub(crate) fn traffic_control_device_type_to_cpp(
2537    sign_type: &TrafficControlDeviceType,
2538) -> maliput_sys::api::rules::ffi::TrafficControlDeviceType {
2539    match sign_type {
2540        TrafficSignType::None => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNone,
2541        TrafficSignType::Other => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kOther,
2542        TrafficSignType::Stop => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kStop,
2543        TrafficSignType::Yield => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kYield,
2544        TrafficSignType::SpeedLimit => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSpeedLimit,
2545        TrafficSignType::NoEntry => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNoEntry,
2546        TrafficSignType::OneWay => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kOneWay,
2547        TrafficSignType::PedestrianCrossing => {
2548            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPedestrianCrossing
2549        }
2550        TrafficSignType::NoLeftTurn => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNoLeftTurn,
2551        TrafficSignType::NoRightTurn => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNoRightTurn,
2552        TrafficSignType::NoUTurn => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNoUTurn,
2553        TrafficSignType::SchoolZone => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSchoolZone,
2554        TrafficSignType::Construction => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kConstruction,
2555        TrafficSignType::RailroadCrossing => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRailroadCrossing,
2556        TrafficSignType::NoOvertaking => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNoOvertaking,
2557        TrafficSignType::AllWay => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kAllWay,
2558        TrafficSignType::NoUTurnLeft => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNoUTurnLeft,
2559        TrafficSignType::NoUTurnRight => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNoUTurnRight,
2560        TrafficSignType::StopLine => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kStopLine,
2561        TrafficSignType::Crosswalk => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kCrosswalk,
2562        TrafficSignType::DangerSpot => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDangerSpot,
2563        TrafficSignType::ZebraCrossing => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kZebraCrossing,
2564        TrafficSignType::Flight => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kFlight,
2565        TrafficSignType::Cattle => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kCattle,
2566        TrafficSignType::HorseRiders => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHorseRiders,
2567        TrafficSignType::Amphibians => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kAmphibians,
2568        TrafficSignType::FallingRocks => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kFallingRocks,
2569        TrafficSignType::SnowOrIce => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSnowOrIce,
2570        TrafficSignType::LooseGravel => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kLooseGravel,
2571        TrafficSignType::Waterside => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kWaterside,
2572        TrafficSignType::Clearance => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kClearance,
2573        TrafficSignType::MovableBridge => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kMovableBridge,
2574        TrafficSignType::RightBeforeLeftNextIntersection => {
2575            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRightBeforeLeftNextIntersection
2576        }
2577        TrafficSignType::TurnLeft => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTurnLeft,
2578        TrafficSignType::TurnRight => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTurnRight,
2579        TrafficSignType::DoubleTurnLeft => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDoubleTurnLeft,
2580        TrafficSignType::DoubleTurnRight => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDoubleTurnRight,
2581        TrafficSignType::HillDownwards => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHillDownwards,
2582        TrafficSignType::HillUpwards => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHillUpwards,
2583        TrafficSignType::UnevenRoad => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kUnevenRoad,
2584        TrafficSignType::RoadSlipperyWetOrDirty => {
2585            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRoadSlipperyWetOrDirty
2586        }
2587        TrafficSignType::SideWinds => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSideWinds,
2588        TrafficSignType::RoadNarrowing => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRoadNarrowing,
2589        TrafficSignType::RoadNarrowingRight => {
2590            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRoadNarrowingRight
2591        }
2592        TrafficSignType::RoadNarrowingLeft => {
2593            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRoadNarrowingLeft
2594        }
2595        TrafficSignType::RoadWorks => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRoadWorks,
2596        TrafficSignType::TrafficQueues => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTrafficQueues,
2597        TrafficSignType::TwoWayTraffic => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTwoWayTraffic,
2598        TrafficSignType::AttentionTrafficLight => {
2599            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kAttentionTrafficLight
2600        }
2601        TrafficSignType::Pedestrians => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPedestrians,
2602        TrafficSignType::ChildrenCrossing => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kChildrenCrossing,
2603        TrafficSignType::CycleRoute => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kCycleRoute,
2604        TrafficSignType::DeerCrossing => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDeerCrossing,
2605        TrafficSignType::UngatedLevelCrossing => {
2606            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kUngatedLevelCrossing
2607        }
2608        TrafficSignType::LevelCrossingMarker => {
2609            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kLevelCrossingMarker
2610        }
2611        TrafficSignType::RailwayTrafficPriority => {
2612            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRailwayTrafficPriority
2613        }
2614        TrafficSignType::GiveWay => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kGiveWay,
2615        TrafficSignType::PriorityToOppositeDirection => {
2616            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPriorityToOppositeDirection
2617        }
2618        TrafficSignType::PriorityToOppositeDirectionUpsideDown => {
2619            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPriorityToOppositeDirectionUpsideDown
2620        }
2621        TrafficSignType::PrescribedLeftTurn => {
2622            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPrescribedLeftTurn
2623        }
2624        TrafficSignType::PrescribedRightTurn => {
2625            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPrescribedRightTurn
2626        }
2627        TrafficSignType::PrescribedStraight => {
2628            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPrescribedStraight
2629        }
2630        TrafficSignType::PrescribedRightWay => {
2631            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPrescribedRightWay
2632        }
2633        TrafficSignType::PrescribedLeftWay => {
2634            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPrescribedLeftWay
2635        }
2636        TrafficSignType::PrescribedRightTurnAndStraight => {
2637            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPrescribedRightTurnAndStraight
2638        }
2639        TrafficSignType::PrescribedLeftTurnAndStraight => {
2640            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPrescribedLeftTurnAndStraight
2641        }
2642        TrafficSignType::PrescribedLeftTurnAndRightTurn => {
2643            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPrescribedLeftTurnAndRightTurn
2644        }
2645        TrafficSignType::PrescribedLeftTurnRightTurnAndStraight => {
2646            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPrescribedLeftTurnRightTurnAndStraight
2647        }
2648        TrafficSignType::Roundabout => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRoundabout,
2649        TrafficSignType::OnewayLeft => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kOnewayLeft,
2650        TrafficSignType::OnewayRight => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kOnewayRight,
2651        TrafficSignType::PassLeft => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPassLeft,
2652        TrafficSignType::PassRight => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPassRight,
2653        TrafficSignType::SideLaneOpenForTraffic => {
2654            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSideLaneOpenForTraffic
2655        }
2656        TrafficSignType::SideLaneClosedForTraffic => {
2657            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSideLaneClosedForTraffic
2658        }
2659        TrafficSignType::SideLaneClosingForTraffic => {
2660            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSideLaneClosingForTraffic
2661        }
2662        TrafficSignType::BusStop => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kBusStop,
2663        TrafficSignType::TaxiStand => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTaxiStand,
2664        TrafficSignType::BicyclesOnly => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kBicyclesOnly,
2665        TrafficSignType::HorseRidersOnly => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHorseRidersOnly,
2666        TrafficSignType::PedestriansOnly => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPedestriansOnly,
2667        TrafficSignType::BicyclesPedestriansSharedOnly => {
2668            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kBicyclesPedestriansSharedOnly
2669        }
2670        TrafficSignType::BicyclesPedestriansSeparatedLeftOnly => {
2671            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kBicyclesPedestriansSeparatedLeftOnly
2672        }
2673        TrafficSignType::BicyclesPedestriansSeparatedRightOnly => {
2674            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kBicyclesPedestriansSeparatedRightOnly
2675        }
2676        TrafficSignType::PedestrianZoneBegin => {
2677            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPedestrianZoneBegin
2678        }
2679        TrafficSignType::PedestrianZoneEnd => {
2680            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPedestrianZoneEnd
2681        }
2682        TrafficSignType::BicycleRoadBegin => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kBicycleRoadBegin,
2683        TrafficSignType::BicycleRoadEnd => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kBicycleRoadEnd,
2684        TrafficSignType::BusLane => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kBusLane,
2685        TrafficSignType::BusLaneBegin => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kBusLaneBegin,
2686        TrafficSignType::BusLaneEnd => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kBusLaneEnd,
2687        TrafficSignType::AllProhibited => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kAllProhibited,
2688        TrafficSignType::MotorizedMultitrackProhibited => {
2689            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kMotorizedMultitrackProhibited
2690        }
2691        TrafficSignType::TrucksProhibited => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTrucksProhibited,
2692        TrafficSignType::BicyclesProhibited => {
2693            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kBicyclesProhibited
2694        }
2695        TrafficSignType::MotorcyclesProhibited => {
2696            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kMotorcyclesProhibited
2697        }
2698        TrafficSignType::MopedsProhibited => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kMopedsProhibited,
2699        TrafficSignType::HorseRidersProhibited => {
2700            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHorseRidersProhibited
2701        }
2702        TrafficSignType::HorseCarriagesProhibited => {
2703            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHorseCarriagesProhibited
2704        }
2705        TrafficSignType::CattleProhibited => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kCattleProhibited,
2706        TrafficSignType::BusesProhibited => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kBusesProhibited,
2707        TrafficSignType::CarsProhibited => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kCarsProhibited,
2708        TrafficSignType::CarsTrailersProhibited => {
2709            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kCarsTrailersProhibited
2710        }
2711        TrafficSignType::TrucksTrailersProhibited => {
2712            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTrucksTrailersProhibited
2713        }
2714        TrafficSignType::TractorsProhibited => {
2715            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTractorsProhibited
2716        }
2717        TrafficSignType::PedestriansProhibited => {
2718            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPedestriansProhibited
2719        }
2720        TrafficSignType::MotorVehiclesProhibited => {
2721            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kMotorVehiclesProhibited
2722        }
2723        TrafficSignType::HazardousGoodsVehiclesProhibited => {
2724            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHazardousGoodsVehiclesProhibited
2725        }
2726        TrafficSignType::OverWeightVehiclesProhibited => {
2727            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kOverWeightVehiclesProhibited
2728        }
2729        TrafficSignType::VehiclesAxleOverWeightProhibited => {
2730            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kVehiclesAxleOverWeightProhibited
2731        }
2732        TrafficSignType::VehiclesExcessWidthProhibited => {
2733            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kVehiclesExcessWidthProhibited
2734        }
2735        TrafficSignType::VehiclesExcessHeightProhibited => {
2736            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kVehiclesExcessHeightProhibited
2737        }
2738        TrafficSignType::VehiclesExcessLengthProhibited => {
2739            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kVehiclesExcessLengthProhibited
2740        }
2741        TrafficSignType::DoNotEnter => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDoNotEnter,
2742        TrafficSignType::SnowChainsRequired => {
2743            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSnowChainsRequired
2744        }
2745        TrafficSignType::WaterPollutantVehiclesProhibited => {
2746            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kWaterPollutantVehiclesProhibited
2747        }
2748        TrafficSignType::EnvironmentalZoneBegin => {
2749            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kEnvironmentalZoneBegin
2750        }
2751        TrafficSignType::EnvironmentalZoneEnd => {
2752            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kEnvironmentalZoneEnd
2753        }
2754        TrafficSignType::PrescribedUTurnLeft => {
2755            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPrescribedUTurnLeft
2756        }
2757        TrafficSignType::PrescribedUTurnRight => {
2758            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPrescribedUTurnRight
2759        }
2760        TrafficSignType::MinimumDistanceForTrucks => {
2761            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kMinimumDistanceForTrucks
2762        }
2763        TrafficSignType::SpeedLimitBegin => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSpeedLimitBegin,
2764        TrafficSignType::SpeedLimitZoneBegin => {
2765            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSpeedLimitZoneBegin
2766        }
2767        TrafficSignType::SpeedLimitZoneEnd => {
2768            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSpeedLimitZoneEnd
2769        }
2770        TrafficSignType::MinimumSpeedBegin => {
2771            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kMinimumSpeedBegin
2772        }
2773        TrafficSignType::OvertakingBanBegin => {
2774            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kOvertakingBanBegin
2775        }
2776        TrafficSignType::OvertakingBanForTrucksBegin => {
2777            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kOvertakingBanForTrucksBegin
2778        }
2779        TrafficSignType::SpeedLimitEnd => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSpeedLimitEnd,
2780        TrafficSignType::MinimumSpeedEnd => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kMinimumSpeedEnd,
2781        TrafficSignType::OvertakingBanEnd => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kOvertakingBanEnd,
2782        TrafficSignType::OvertakingBanForTrucksEnd => {
2783            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kOvertakingBanForTrucksEnd
2784        }
2785        TrafficSignType::AllRestrictionsEnd => {
2786            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kAllRestrictionsEnd
2787        }
2788        TrafficSignType::NoStopping => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNoStopping,
2789        TrafficSignType::NoParking => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNoParking,
2790        TrafficSignType::NoParkingZoneBegin => {
2791            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNoParkingZoneBegin
2792        }
2793        TrafficSignType::NoParkingZoneEnd => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNoParkingZoneEnd,
2794        TrafficSignType::RightOfWayNextIntersection => {
2795            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRightOfWayNextIntersection
2796        }
2797        TrafficSignType::RightOfWayBegin => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRightOfWayBegin,
2798        TrafficSignType::RightOfWayEnd => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRightOfWayEnd,
2799        TrafficSignType::PriorityOverOppositeDirection => {
2800            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPriorityOverOppositeDirection
2801        }
2802        TrafficSignType::PriorityOverOppositeDirectionUpsideDown => {
2803            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPriorityOverOppositeDirectionUpsideDown
2804        }
2805        TrafficSignType::TownBegin => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTownBegin,
2806        TrafficSignType::TownEnd => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTownEnd,
2807        TrafficSignType::CarParking => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kCarParking,
2808        TrafficSignType::CarParkingZoneBegin => {
2809            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kCarParkingZoneBegin
2810        }
2811        TrafficSignType::CarParkingZoneEnd => {
2812            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kCarParkingZoneEnd
2813        }
2814        TrafficSignType::SidewalkHalfParkingLeft => {
2815            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSidewalkHalfParkingLeft
2816        }
2817        TrafficSignType::SidewalkHalfParkingRight => {
2818            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSidewalkHalfParkingRight
2819        }
2820        TrafficSignType::SidewalkParkingLeft => {
2821            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSidewalkParkingLeft
2822        }
2823        TrafficSignType::SidewalkParkingRight => {
2824            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSidewalkParkingRight
2825        }
2826        TrafficSignType::SidewalkPerpendicularHalfParkingLeft => {
2827            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSidewalkPerpendicularHalfParkingLeft
2828        }
2829        TrafficSignType::SidewalkPerpendicularHalfParkingRight => {
2830            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSidewalkPerpendicularHalfParkingRight
2831        }
2832        TrafficSignType::SidewalkPerpendicularParkingLeft => {
2833            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSidewalkPerpendicularParkingLeft
2834        }
2835        TrafficSignType::SidewalkPerpendicularParkingRight => {
2836            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSidewalkPerpendicularParkingRight
2837        }
2838        TrafficSignType::LivingStreetBegin => {
2839            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kLivingStreetBegin
2840        }
2841        TrafficSignType::LivingStreetEnd => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kLivingStreetEnd,
2842        TrafficSignType::Tunnel => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTunnel,
2843        TrafficSignType::EmergencyStoppingLeft => {
2844            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kEmergencyStoppingLeft
2845        }
2846        TrafficSignType::EmergencyStoppingRight => {
2847            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kEmergencyStoppingRight
2848        }
2849        TrafficSignType::HighwayBegin => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHighwayBegin,
2850        TrafficSignType::HighwayEnd => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHighwayEnd,
2851        TrafficSignType::ExpresswayBegin => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kExpresswayBegin,
2852        TrafficSignType::ExpresswayEnd => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kExpresswayEnd,
2853        TrafficSignType::NamedHighwayExit => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNamedHighwayExit,
2854        TrafficSignType::NamedExpresswayExit => {
2855            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNamedExpresswayExit
2856        }
2857        TrafficSignType::NamedRoadExit => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNamedRoadExit,
2858        TrafficSignType::HighwayExit => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHighwayExit,
2859        TrafficSignType::ExpresswayExit => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kExpresswayExit,
2860        TrafficSignType::OnewayStreet => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kOnewayStreet,
2861        TrafficSignType::CrossingGuards => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kCrossingGuards,
2862        TrafficSignType::Deadend => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDeadend,
2863        TrafficSignType::DeadendExcludingDesignatedActors => {
2864            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDeadendExcludingDesignatedActors
2865        }
2866        TrafficSignType::FirstAidStation => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kFirstAidStation,
2867        TrafficSignType::PoliceStation => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPoliceStation,
2868        TrafficSignType::Telephone => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTelephone,
2869        TrafficSignType::FillingStation => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kFillingStation,
2870        TrafficSignType::Hotel => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHotel,
2871        TrafficSignType::Inn => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kInn,
2872        TrafficSignType::Kiosk => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kKiosk,
2873        TrafficSignType::Toilet => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kToilet,
2874        TrafficSignType::Chapel => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kChapel,
2875        TrafficSignType::TouristInfo => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTouristInfo,
2876        TrafficSignType::RepairService => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRepairService,
2877        TrafficSignType::PedestrianUnderpass => {
2878            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPedestrianUnderpass
2879        }
2880        TrafficSignType::PedestrianBridge => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPedestrianBridge,
2881        TrafficSignType::CamperPlace => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kCamperPlace,
2882        TrafficSignType::AdvisorySpeedLimitBegin => {
2883            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kAdvisorySpeedLimitBegin
2884        }
2885        TrafficSignType::AdvisorySpeedLimitEnd => {
2886            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kAdvisorySpeedLimitEnd
2887        }
2888        TrafficSignType::PlaceName => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPlaceName,
2889        TrafficSignType::TouristAttraction => {
2890            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTouristAttraction
2891        }
2892        TrafficSignType::TouristRoute => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTouristRoute,
2893        TrafficSignType::TouristArea => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTouristArea,
2894        TrafficSignType::ShoulderNotPassableMotorVehicles => {
2895            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kShoulderNotPassableMotorVehicles
2896        }
2897        TrafficSignType::ShoulderUnsafeTrucksTractors => {
2898            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kShoulderUnsafeTrucksTractors
2899        }
2900        TrafficSignType::TollBegin => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTollBegin,
2901        TrafficSignType::TollEnd => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTollEnd,
2902        TrafficSignType::TollRoad => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTollRoad,
2903        TrafficSignType::Customs => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kCustoms,
2904        TrafficSignType::InternationalBorderInfo => {
2905            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kInternationalBorderInfo
2906        }
2907        TrafficSignType::StreetlightRedBand => {
2908            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kStreetlightRedBand
2909        }
2910        TrafficSignType::FederalHighwayRouteNumber => {
2911            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kFederalHighwayRouteNumber
2912        }
2913        TrafficSignType::HighwayRouteNumber => {
2914            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHighwayRouteNumber
2915        }
2916        TrafficSignType::HighwayInterchangeNumber => {
2917            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHighwayInterchangeNumber
2918        }
2919        TrafficSignType::EuropeanRouteNumber => {
2920            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kEuropeanRouteNumber
2921        }
2922        TrafficSignType::FederalHighwayDirectionLeft => {
2923            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kFederalHighwayDirectionLeft
2924        }
2925        TrafficSignType::FederalHighwayDirectionRight => {
2926            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kFederalHighwayDirectionRight
2927        }
2928        TrafficSignType::PrimaryRoadDirectionLeft => {
2929            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPrimaryRoadDirectionLeft
2930        }
2931        TrafficSignType::PrimaryRoadDirectionRight => {
2932            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPrimaryRoadDirectionRight
2933        }
2934        TrafficSignType::SecondaryRoadDirectionLeft => {
2935            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSecondaryRoadDirectionLeft
2936        }
2937        TrafficSignType::SecondaryRoadDirectionRight => {
2938            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSecondaryRoadDirectionRight
2939        }
2940        TrafficSignType::DirectionDesignatedActorsLeft => {
2941            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDirectionDesignatedActorsLeft
2942        }
2943        TrafficSignType::DirectionDesignatedActorsRight => {
2944            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDirectionDesignatedActorsRight
2945        }
2946        TrafficSignType::RoutingDesignatedActors => {
2947            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRoutingDesignatedActors
2948        }
2949        TrafficSignType::DirectionToHighwayLeft => {
2950            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDirectionToHighwayLeft
2951        }
2952        TrafficSignType::DirectionToHighwayRight => {
2953            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDirectionToHighwayRight
2954        }
2955        TrafficSignType::DirectionToLocalDestinationLeft => {
2956            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDirectionToLocalDestinationLeft
2957        }
2958        TrafficSignType::DirectionToLocalDestinationRight => {
2959            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDirectionToLocalDestinationRight
2960        }
2961        TrafficSignType::ConsolidatedDirections => {
2962            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kConsolidatedDirections
2963        }
2964        TrafficSignType::StreetName => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kStreetName,
2965        TrafficSignType::DirectionPreannouncement => {
2966            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDirectionPreannouncement
2967        }
2968        TrafficSignType::DirectionPreannouncementLaneConfig => {
2969            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDirectionPreannouncementLaneConfig
2970        }
2971        TrafficSignType::DirectionPreannouncementHighwayEntries => {
2972            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDirectionPreannouncementHighwayEntries
2973        }
2974        TrafficSignType::HighwayAnnouncement => {
2975            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHighwayAnnouncement
2976        }
2977        TrafficSignType::OtherRoadAnnouncement => {
2978            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kOtherRoadAnnouncement
2979        }
2980        TrafficSignType::HighwayAnnouncementTruckStop => {
2981            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHighwayAnnouncementTruckStop
2982        }
2983        TrafficSignType::HighwayPreannouncementDirections => {
2984            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHighwayPreannouncementDirections
2985        }
2986        TrafficSignType::PoleExit => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPoleExit,
2987        TrafficSignType::HighwayDistanceBoard => {
2988            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHighwayDistanceBoard
2989        }
2990        TrafficSignType::DetourLeft => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDetourLeft,
2991        TrafficSignType::DetourRight => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDetourRight,
2992        TrafficSignType::NumberedDetour => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNumberedDetour,
2993        TrafficSignType::DetourBegin => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDetourBegin,
2994        TrafficSignType::DetourEnd => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDetourEnd,
2995        TrafficSignType::DetourRoutingBoard => {
2996            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDetourRoutingBoard
2997        }
2998        TrafficSignType::OptionalDetour => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kOptionalDetour,
2999        TrafficSignType::OptionalDetourRouting => {
3000            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kOptionalDetourRouting
3001        }
3002        TrafficSignType::RouteRecommendation => {
3003            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRouteRecommendation
3004        }
3005        TrafficSignType::RouteRecommendationEnd => {
3006            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRouteRecommendationEnd
3007        }
3008        TrafficSignType::AnnounceLaneTransitionLeft => {
3009            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kAnnounceLaneTransitionLeft
3010        }
3011        TrafficSignType::AnnounceLaneTransitionRight => {
3012            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kAnnounceLaneTransitionRight
3013        }
3014        TrafficSignType::AnnounceRightLaneEnd => {
3015            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kAnnounceRightLaneEnd
3016        }
3017        TrafficSignType::AnnounceLeftLaneEnd => {
3018            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kAnnounceLeftLaneEnd
3019        }
3020        TrafficSignType::AnnounceRightLaneBegin => {
3021            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kAnnounceRightLaneBegin
3022        }
3023        TrafficSignType::AnnounceLeftLaneBegin => {
3024            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kAnnounceLeftLaneBegin
3025        }
3026        TrafficSignType::AnnounceLaneConsolidation => {
3027            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kAnnounceLaneConsolidation
3028        }
3029        TrafficSignType::DetourCityBlock => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDetourCityBlock,
3030        TrafficSignType::Gate => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kGate,
3031        TrafficSignType::PoleWarning => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPoleWarning,
3032        TrafficSignType::TrafficCone => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTrafficCone,
3033        TrafficSignType::MobileLaneClosure => {
3034            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kMobileLaneClosure
3035        }
3036        TrafficSignType::ReflectorPost => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kReflectorPost,
3037        TrafficSignType::DirectionalBoardWarning => {
3038            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kDirectionalBoardWarning
3039        }
3040        TrafficSignType::GuidingPlate => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kGuidingPlate,
3041        TrafficSignType::GuidingPlateWedges => {
3042            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kGuidingPlateWedges
3043        }
3044        TrafficSignType::ParkingHazard => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kParkingHazard,
3045        TrafficSignType::TrafficLightGreenArrow => {
3046            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTrafficLightGreenArrow
3047        }
3048        TrafficSignType::Text => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kText,
3049        TrafficSignType::Space => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSpace,
3050        TrafficSignType::Time => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTime,
3051        TrafficSignType::Arrow => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kArrow,
3052        TrafficSignType::ConstrainedTo => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kConstrainedTo,
3053        TrafficSignType::Except => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kExcept,
3054        TrafficSignType::ValidForDistance => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kValidForDistance,
3055        TrafficSignType::PriorityRoadBottomLeftFourWay => {
3056            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPriorityRoadBottomLeftFourWay
3057        }
3058        TrafficSignType::PriorityRoadTopLeftFourWay => {
3059            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPriorityRoadTopLeftFourWay
3060        }
3061        TrafficSignType::PriorityRoadBottomLeftThreeWayStraight => {
3062            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPriorityRoadBottomLeftThreeWayStraight
3063        }
3064        TrafficSignType::PriorityRoadBottomLeftThreeWaySideways => {
3065            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPriorityRoadBottomLeftThreeWaySideways
3066        }
3067        TrafficSignType::PriorityRoadTopLeftThreeWayStraight => {
3068            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPriorityRoadTopLeftThreeWayStraight
3069        }
3070        TrafficSignType::PriorityRoadBottomRightFourWay => {
3071            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPriorityRoadBottomRightFourWay
3072        }
3073        TrafficSignType::PriorityRoadTopRightFourWay => {
3074            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPriorityRoadTopRightFourWay
3075        }
3076        TrafficSignType::PriorityRoadBottomRightThreeWayStraight => {
3077            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPriorityRoadBottomRightThreeWayStraight
3078        }
3079        TrafficSignType::PriorityRoadBottomRightThreeWaySideway => {
3080            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPriorityRoadBottomRightThreeWaySideway
3081        }
3082        TrafficSignType::PriorityRoadTopRightThreeWayStraight => {
3083            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kPriorityRoadTopRightThreeWayStraight
3084        }
3085        TrafficSignType::ValidInDistance => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kValidInDistance,
3086        TrafficSignType::StopIn => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kStopIn,
3087        TrafficSignType::LeftArrow => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kLeftArrow,
3088        TrafficSignType::LeftBendArrow => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kLeftBendArrow,
3089        TrafficSignType::RightArrow => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRightArrow,
3090        TrafficSignType::RightBendArrow => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRightBendArrow,
3091        TrafficSignType::Accident => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kAccident,
3092        TrafficSignType::Snow => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSnow,
3093        TrafficSignType::Fog => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kFog,
3094        TrafficSignType::RollingHighwayInformation => {
3095            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRollingHighwayInformation
3096        }
3097        TrafficSignType::Services => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kServices,
3098        TrafficSignType::TimeRange => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTimeRange,
3099        TrafficSignType::ParkingDiscTimeRestriction => {
3100            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kParkingDiscTimeRestriction
3101        }
3102        TrafficSignType::Weight => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kWeight,
3103        TrafficSignType::Wet => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kWet,
3104        TrafficSignType::ParkingConstraint => {
3105            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kParkingConstraint
3106        }
3107        TrafficSignType::NoWaitingSideStripes => {
3108            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNoWaitingSideStripes
3109        }
3110        TrafficSignType::Rain => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kRain,
3111        TrafficSignType::SnowRain => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kSnowRain,
3112        TrafficSignType::Night => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kNight,
3113        TrafficSignType::Stop4Way => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kStop4Way,
3114        TrafficSignType::Truck => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTruck,
3115        TrafficSignType::TractorsMayBePassed => {
3116            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTractorsMayBePassed
3117        }
3118        TrafficSignType::Hazardous => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kHazardous,
3119        TrafficSignType::Trailer => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kTrailer,
3120        TrafficSignType::Zone => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kZone,
3121        TrafficSignType::Motorcycle => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kMotorcycle,
3122        TrafficSignType::MotorcycleAllowed => {
3123            maliput_sys::api::rules::ffi::TrafficControlDeviceType::kMotorcycleAllowed
3124        }
3125        TrafficSignType::Car => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kCar,
3126        TrafficSignType::EmergencyLane => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kEmergencyLane,
3127        TrafficSignType::Unknown => maliput_sys::api::rules::ffi::TrafficControlDeviceType::kUnknown,
3128    }
3129}
3130
3131fn traffic_sign_value_unit_from_cpp(unit: &maliput_sys::api::rules::ffi::TrafficSignValueUnit) -> TrafficSignValueUnit {
3132    match *unit {
3133        maliput_sys::api::rules::ffi::TrafficSignValueUnit::kMetersPerSecond => TrafficSignValueUnit::MetersPerSecond,
3134        maliput_sys::api::rules::ffi::TrafficSignValueUnit::kKilometersPerHour => {
3135            TrafficSignValueUnit::KilometersPerHour
3136        }
3137        maliput_sys::api::rules::ffi::TrafficSignValueUnit::kMilesPerHour => TrafficSignValueUnit::MilesPerHour,
3138        maliput_sys::api::rules::ffi::TrafficSignValueUnit::kMeters => TrafficSignValueUnit::Meters,
3139        maliput_sys::api::rules::ffi::TrafficSignValueUnit::kKilometers => TrafficSignValueUnit::Kilometers,
3140        maliput_sys::api::rules::ffi::TrafficSignValueUnit::kFeet => TrafficSignValueUnit::Feet,
3141        maliput_sys::api::rules::ffi::TrafficSignValueUnit::kMiles => TrafficSignValueUnit::Miles,
3142        maliput_sys::api::rules::ffi::TrafficSignValueUnit::kPercent => TrafficSignValueUnit::Percent,
3143        maliput_sys::api::rules::ffi::TrafficSignValueUnit::kKilograms => TrafficSignValueUnit::Kilograms,
3144        maliput_sys::api::rules::ffi::TrafficSignValueUnit::kMetricTons => TrafficSignValueUnit::MetricTons,
3145        _ => panic!("Invalid traffic sign value unit"),
3146    }
3147}
3148
3149/// Interface for accessing the [TrafficSign]s in the [super::RoadNetwork].
3150pub struct TrafficSignBook<'a> {
3151    pub(super) traffic_sign_book: &'a maliput_sys::api::rules::ffi::TrafficSignBook,
3152}
3153
3154impl<'a> TrafficSignBook<'a> {
3155    /// Gets all the [TrafficSign]s in the [TrafficSignBook].
3156    ///
3157    /// # Returns
3158    /// A vector of [TrafficSign]s.
3159    pub fn traffic_signs(&self) -> Vec<TrafficSign<'_>> {
3160        let traffic_signs_cpp = maliput_sys::api::rules::ffi::TrafficSignBook_TrafficSigns(self.traffic_sign_book);
3161        traffic_signs_cpp
3162            .into_iter()
3163            .map(|ts| TrafficSign {
3164                traffic_sign: unsafe { ts.traffic_sign.as_ref().expect("TrafficSign pointer is null") },
3165            })
3166            .collect::<Vec<TrafficSign>>()
3167    }
3168
3169    /// Gets a [TrafficSign] by its id.
3170    ///
3171    /// # Arguments
3172    /// * `id` - The id of the [TrafficSign].
3173    ///
3174    /// # Returns
3175    /// The [TrafficSign] with the given id, or `None` if not found.
3176    pub fn get_traffic_sign(&self, id: &String) -> Option<TrafficSign<'_>> {
3177        let ptr = maliput_sys::api::rules::ffi::TrafficSignBook_GetTrafficSign(self.traffic_sign_book, id);
3178        if ptr.is_null() {
3179            return None;
3180        }
3181        Some(TrafficSign {
3182            traffic_sign: unsafe { ptr.as_ref().expect("Unable to get underlying traffic sign pointer") },
3183        })
3184    }
3185
3186    /// Gets all [TrafficSign]s whose `related_lanes()` includes the given lane ID.
3187    ///
3188    /// # Arguments
3189    /// * `lane_id` - The lane ID to filter by.
3190    ///
3191    /// # Returns
3192    /// A vector of [TrafficSign]s associated with the given lane.
3193    pub fn find_by_lane(&self, lane_id: &String) -> Vec<TrafficSign<'_>> {
3194        let traffic_signs_cpp =
3195            maliput_sys::api::rules::ffi::TrafficSignBook_FindByLane(self.traffic_sign_book, lane_id);
3196        traffic_signs_cpp
3197            .into_iter()
3198            .map(|ts| TrafficSign {
3199                traffic_sign: unsafe { ts.traffic_sign.as_ref().expect("TrafficSign pointer is null") },
3200            })
3201            .collect::<Vec<TrafficSign>>()
3202    }
3203
3204    /// Gets all [TrafficSign]s of the given [TrafficSignType].
3205    ///
3206    /// # Arguments
3207    /// * `sign_type` - The [TrafficSignType] to filter by.
3208    ///
3209    /// # Returns
3210    /// A vector of [TrafficSign]s of the given type.
3211    pub fn find_by_type(&self, sign_type: &TrafficSignType) -> Vec<TrafficSign<'_>> {
3212        let sign_type_ffi = traffic_control_device_type_to_cpp(sign_type);
3213        let traffic_signs_cpp =
3214            maliput_sys::api::rules::ffi::TrafficSignBook_FindByType(self.traffic_sign_book, sign_type_ffi);
3215        traffic_signs_cpp
3216            .into_iter()
3217            .map(|ts| TrafficSign {
3218                traffic_sign: unsafe { ts.traffic_sign.as_ref().expect("TrafficSign pointer is null") },
3219            })
3220            .collect::<Vec<TrafficSign>>()
3221    }
3222}
3223
3224/// Models a physical traffic sign — a static, passive signaling device placed
3225/// along or above the road to convey regulatory, warning, or informational
3226/// messages to road users.
3227///
3228/// Unlike [TrafficLight], traffic signs do not expose phase-based bulb states.
3229/// A sign may still be marked as dynamic or movable by backend metadata.
3230pub struct TrafficSign<'a> {
3231    pub traffic_sign: &'a maliput_sys::api::rules::ffi::TrafficSign,
3232}
3233
3234impl<'a> TrafficSign<'a> {
3235    /// Gets the unique identifier of the [TrafficSign].
3236    ///
3237    /// # Returns
3238    /// The id of the [TrafficSign].
3239    pub fn id(&self) -> String {
3240        maliput_sys::api::rules::ffi::TrafficSign_id(self.traffic_sign)
3241    }
3242
3243    /// Gets the [TrafficSignType] of the [TrafficSign].
3244    ///
3245    /// # Returns
3246    /// The [TrafficSignType].
3247    pub fn sign_type(&self) -> TrafficSignType {
3248        let sign_type = maliput_sys::api::rules::ffi::TrafficSign_type(self.traffic_sign);
3249        traffic_control_device_type_from_cpp(&sign_type)
3250    }
3251
3252    /// Gets the position of the [TrafficSign] in the road network's Inertial frame.
3253    ///
3254    /// # Returns
3255    /// An [super::InertialPosition] representing the position of the [TrafficSign].
3256    pub fn position_road_network(&self) -> super::InertialPosition {
3257        let inertial_position = maliput_sys::api::rules::ffi::TrafficSign_position_road_network(self.traffic_sign);
3258        super::InertialPosition { ip: inertial_position }
3259    }
3260
3261    /// Gets the orientation of the [TrafficSign] in the road network's Inertial frame.
3262    ///
3263    /// # Returns
3264    /// An [super::Rotation] representing the orientation of the [TrafficSign].
3265    pub fn orientation_road_network(&self) -> super::Rotation {
3266        let rotation = maliput_sys::api::rules::ffi::TrafficSign_orientation_road_network(self.traffic_sign);
3267        super::Rotation { r: rotation }
3268    }
3269
3270    /// Gets the optional text message displayed on the [TrafficSign].
3271    ///
3272    /// # Returns
3273    /// `Some(String)` if a message is set, `None` otherwise.
3274    pub fn message(&self) -> Option<String> {
3275        let wrapper = maliput_sys::api::rules::ffi::TrafficSign_message(self.traffic_sign);
3276        if wrapper.is_null() {
3277            return None;
3278        }
3279        Some(wrapper.value.clone())
3280    }
3281
3282    /// Returns whether this sign can change semantically over time.
3283    pub fn is_dynamic(&self) -> bool {
3284        maliput_sys::api::rules::ffi::TrafficSign::is_dynamic(self.traffic_sign)
3285    }
3286
3287    /// Returns whether this sign's position can change.
3288    pub fn is_movable(&self) -> bool {
3289        maliput_sys::api::rules::ffi::TrafficSign::is_movable(self.traffic_sign)
3290    }
3291
3292    /// Gets the lane IDs that this sign is physically relevant to.
3293    ///
3294    /// # Returns
3295    /// A vector of lane ID strings.
3296    pub fn related_lanes(&self) -> Vec<String> {
3297        maliput_sys::api::rules::ffi::TrafficSign_related_lanes(self.traffic_sign)
3298    }
3299
3300    /// Gets the bounding box of the [TrafficSign].
3301    ///
3302    /// # Returns
3303    /// A [crate::math::BoundingBox] describing the sign's oriented bounding volume.
3304    /// The box position is the centroid, `box_size` gives full extents, and `orientation`
3305    /// is expressed as roll-pitch-yaw angles.
3306    pub fn bounding_box(&self) -> crate::math::BoundingBox {
3307        let b = maliput_sys::api::rules::ffi::TrafficSign_bounding_box(self.traffic_sign);
3308        crate::math::BoundingBox { b }
3309    }
3310
3311    /// Gets the optional numeric value associated with the [TrafficSign].
3312    ///
3313    /// # Returns
3314    /// `Some(TrafficSignValue)` if a value is set, `None` otherwise.
3315    pub fn value(&self) -> Option<TrafficSignValue> {
3316        let data = maliput_sys::api::rules::ffi::TrafficSign_value(self.traffic_sign);
3317        if !data.has_value {
3318            return None;
3319        }
3320        Some(TrafficSignValue {
3321            value: data.value,
3322            unit: traffic_sign_value_unit_from_cpp(&data.unit),
3323        })
3324    }
3325
3326    /// Returns backend-specific key-value properties for this [TrafficSign].
3327    pub fn properties(&self) -> HashMap<String, String> {
3328        maliput_sys::api::rules::ffi::TrafficSign_properties(self.traffic_sign)
3329            .into_iter()
3330            .map(|p| (p.key, p.value))
3331            .collect()
3332    }
3333
3334    /// Returns the [TrafficSign]s' IDs that depend on this sign, if any.
3335    /// For example, a "Stop" sign may have an associated "All way" sign.
3336    pub fn dependent_signs(&self) -> Vec<String> {
3337        maliput_sys::api::rules::ffi::TrafficSign_dependent_signs(self.traffic_sign)
3338    }
3339}
3340
3341#[cfg(test)]
3342mod tests {
3343    use super::*;
3344
3345    #[test]
3346    fn traffic_sign_type_roundtrips_all_known_variants() {
3347        let variants = [
3348            TrafficSignType::None,
3349            TrafficSignType::Other,
3350            TrafficSignType::Stop,
3351            TrafficSignType::Yield,
3352            TrafficSignType::SpeedLimit,
3353            TrafficSignType::NoEntry,
3354            TrafficSignType::OneWay,
3355            TrafficSignType::PedestrianCrossing,
3356            TrafficSignType::NoLeftTurn,
3357            TrafficSignType::NoRightTurn,
3358            TrafficSignType::NoUTurn,
3359            TrafficSignType::SchoolZone,
3360            TrafficSignType::Construction,
3361            TrafficSignType::RailroadCrossing,
3362            TrafficSignType::NoOvertaking,
3363            TrafficSignType::AllWay,
3364            TrafficSignType::NoUTurnLeft,
3365            TrafficSignType::NoUTurnRight,
3366            TrafficSignType::StopLine,
3367            TrafficSignType::Crosswalk,
3368            TrafficSignType::DangerSpot,
3369            TrafficSignType::ZebraCrossing,
3370            TrafficSignType::Flight,
3371            TrafficSignType::Cattle,
3372            TrafficSignType::HorseRiders,
3373            TrafficSignType::Amphibians,
3374            TrafficSignType::FallingRocks,
3375            TrafficSignType::SnowOrIce,
3376            TrafficSignType::LooseGravel,
3377            TrafficSignType::Waterside,
3378            TrafficSignType::Clearance,
3379            TrafficSignType::MovableBridge,
3380            TrafficSignType::RightBeforeLeftNextIntersection,
3381            TrafficSignType::TurnLeft,
3382            TrafficSignType::TurnRight,
3383            TrafficSignType::DoubleTurnLeft,
3384            TrafficSignType::DoubleTurnRight,
3385            TrafficSignType::HillDownwards,
3386            TrafficSignType::HillUpwards,
3387            TrafficSignType::UnevenRoad,
3388            TrafficSignType::RoadSlipperyWetOrDirty,
3389            TrafficSignType::SideWinds,
3390            TrafficSignType::RoadNarrowing,
3391            TrafficSignType::RoadNarrowingRight,
3392            TrafficSignType::RoadNarrowingLeft,
3393            TrafficSignType::RoadWorks,
3394            TrafficSignType::TrafficQueues,
3395            TrafficSignType::TwoWayTraffic,
3396            TrafficSignType::AttentionTrafficLight,
3397            TrafficSignType::Pedestrians,
3398            TrafficSignType::ChildrenCrossing,
3399            TrafficSignType::CycleRoute,
3400            TrafficSignType::DeerCrossing,
3401            TrafficSignType::UngatedLevelCrossing,
3402            TrafficSignType::LevelCrossingMarker,
3403            TrafficSignType::RailwayTrafficPriority,
3404            TrafficSignType::GiveWay,
3405            TrafficSignType::PriorityToOppositeDirection,
3406            TrafficSignType::PriorityToOppositeDirectionUpsideDown,
3407            TrafficSignType::PrescribedLeftTurn,
3408            TrafficSignType::PrescribedRightTurn,
3409            TrafficSignType::PrescribedStraight,
3410            TrafficSignType::PrescribedRightWay,
3411            TrafficSignType::PrescribedLeftWay,
3412            TrafficSignType::PrescribedRightTurnAndStraight,
3413            TrafficSignType::PrescribedLeftTurnAndStraight,
3414            TrafficSignType::PrescribedLeftTurnAndRightTurn,
3415            TrafficSignType::PrescribedLeftTurnRightTurnAndStraight,
3416            TrafficSignType::Roundabout,
3417            TrafficSignType::OnewayLeft,
3418            TrafficSignType::OnewayRight,
3419            TrafficSignType::PassLeft,
3420            TrafficSignType::PassRight,
3421            TrafficSignType::SideLaneOpenForTraffic,
3422            TrafficSignType::SideLaneClosedForTraffic,
3423            TrafficSignType::SideLaneClosingForTraffic,
3424            TrafficSignType::BusStop,
3425            TrafficSignType::TaxiStand,
3426            TrafficSignType::BicyclesOnly,
3427            TrafficSignType::HorseRidersOnly,
3428            TrafficSignType::PedestriansOnly,
3429            TrafficSignType::BicyclesPedestriansSharedOnly,
3430            TrafficSignType::BicyclesPedestriansSeparatedLeftOnly,
3431            TrafficSignType::BicyclesPedestriansSeparatedRightOnly,
3432            TrafficSignType::PedestrianZoneBegin,
3433            TrafficSignType::PedestrianZoneEnd,
3434            TrafficSignType::BicycleRoadBegin,
3435            TrafficSignType::BicycleRoadEnd,
3436            TrafficSignType::BusLane,
3437            TrafficSignType::BusLaneBegin,
3438            TrafficSignType::BusLaneEnd,
3439            TrafficSignType::AllProhibited,
3440            TrafficSignType::MotorizedMultitrackProhibited,
3441            TrafficSignType::TrucksProhibited,
3442            TrafficSignType::BicyclesProhibited,
3443            TrafficSignType::MotorcyclesProhibited,
3444            TrafficSignType::MopedsProhibited,
3445            TrafficSignType::HorseRidersProhibited,
3446            TrafficSignType::HorseCarriagesProhibited,
3447            TrafficSignType::CattleProhibited,
3448            TrafficSignType::BusesProhibited,
3449            TrafficSignType::CarsProhibited,
3450            TrafficSignType::CarsTrailersProhibited,
3451            TrafficSignType::TrucksTrailersProhibited,
3452            TrafficSignType::TractorsProhibited,
3453            TrafficSignType::PedestriansProhibited,
3454            TrafficSignType::MotorVehiclesProhibited,
3455            TrafficSignType::HazardousGoodsVehiclesProhibited,
3456            TrafficSignType::OverWeightVehiclesProhibited,
3457            TrafficSignType::VehiclesAxleOverWeightProhibited,
3458            TrafficSignType::VehiclesExcessWidthProhibited,
3459            TrafficSignType::VehiclesExcessHeightProhibited,
3460            TrafficSignType::VehiclesExcessLengthProhibited,
3461            TrafficSignType::DoNotEnter,
3462            TrafficSignType::SnowChainsRequired,
3463            TrafficSignType::WaterPollutantVehiclesProhibited,
3464            TrafficSignType::EnvironmentalZoneBegin,
3465            TrafficSignType::EnvironmentalZoneEnd,
3466            TrafficSignType::PrescribedUTurnLeft,
3467            TrafficSignType::PrescribedUTurnRight,
3468            TrafficSignType::MinimumDistanceForTrucks,
3469            TrafficSignType::SpeedLimitBegin,
3470            TrafficSignType::SpeedLimitZoneBegin,
3471            TrafficSignType::SpeedLimitZoneEnd,
3472            TrafficSignType::MinimumSpeedBegin,
3473            TrafficSignType::OvertakingBanBegin,
3474            TrafficSignType::OvertakingBanForTrucksBegin,
3475            TrafficSignType::SpeedLimitEnd,
3476            TrafficSignType::MinimumSpeedEnd,
3477            TrafficSignType::OvertakingBanEnd,
3478            TrafficSignType::OvertakingBanForTrucksEnd,
3479            TrafficSignType::AllRestrictionsEnd,
3480            TrafficSignType::NoStopping,
3481            TrafficSignType::NoParking,
3482            TrafficSignType::NoParkingZoneBegin,
3483            TrafficSignType::NoParkingZoneEnd,
3484            TrafficSignType::RightOfWayNextIntersection,
3485            TrafficSignType::RightOfWayBegin,
3486            TrafficSignType::RightOfWayEnd,
3487            TrafficSignType::PriorityOverOppositeDirection,
3488            TrafficSignType::PriorityOverOppositeDirectionUpsideDown,
3489            TrafficSignType::TownBegin,
3490            TrafficSignType::TownEnd,
3491            TrafficSignType::CarParking,
3492            TrafficSignType::CarParkingZoneBegin,
3493            TrafficSignType::CarParkingZoneEnd,
3494            TrafficSignType::SidewalkHalfParkingLeft,
3495            TrafficSignType::SidewalkHalfParkingRight,
3496            TrafficSignType::SidewalkParkingLeft,
3497            TrafficSignType::SidewalkParkingRight,
3498            TrafficSignType::SidewalkPerpendicularHalfParkingLeft,
3499            TrafficSignType::SidewalkPerpendicularHalfParkingRight,
3500            TrafficSignType::SidewalkPerpendicularParkingLeft,
3501            TrafficSignType::SidewalkPerpendicularParkingRight,
3502            TrafficSignType::LivingStreetBegin,
3503            TrafficSignType::LivingStreetEnd,
3504            TrafficSignType::Tunnel,
3505            TrafficSignType::EmergencyStoppingLeft,
3506            TrafficSignType::EmergencyStoppingRight,
3507            TrafficSignType::HighwayBegin,
3508            TrafficSignType::HighwayEnd,
3509            TrafficSignType::ExpresswayBegin,
3510            TrafficSignType::ExpresswayEnd,
3511            TrafficSignType::NamedHighwayExit,
3512            TrafficSignType::NamedExpresswayExit,
3513            TrafficSignType::NamedRoadExit,
3514            TrafficSignType::HighwayExit,
3515            TrafficSignType::ExpresswayExit,
3516            TrafficSignType::OnewayStreet,
3517            TrafficSignType::CrossingGuards,
3518            TrafficSignType::Deadend,
3519            TrafficSignType::DeadendExcludingDesignatedActors,
3520            TrafficSignType::FirstAidStation,
3521            TrafficSignType::PoliceStation,
3522            TrafficSignType::Telephone,
3523            TrafficSignType::FillingStation,
3524            TrafficSignType::Hotel,
3525            TrafficSignType::Inn,
3526            TrafficSignType::Kiosk,
3527            TrafficSignType::Toilet,
3528            TrafficSignType::Chapel,
3529            TrafficSignType::TouristInfo,
3530            TrafficSignType::RepairService,
3531            TrafficSignType::PedestrianUnderpass,
3532            TrafficSignType::PedestrianBridge,
3533            TrafficSignType::CamperPlace,
3534            TrafficSignType::AdvisorySpeedLimitBegin,
3535            TrafficSignType::AdvisorySpeedLimitEnd,
3536            TrafficSignType::PlaceName,
3537            TrafficSignType::TouristAttraction,
3538            TrafficSignType::TouristRoute,
3539            TrafficSignType::TouristArea,
3540            TrafficSignType::ShoulderNotPassableMotorVehicles,
3541            TrafficSignType::ShoulderUnsafeTrucksTractors,
3542            TrafficSignType::TollBegin,
3543            TrafficSignType::TollEnd,
3544            TrafficSignType::TollRoad,
3545            TrafficSignType::Customs,
3546            TrafficSignType::InternationalBorderInfo,
3547            TrafficSignType::StreetlightRedBand,
3548            TrafficSignType::FederalHighwayRouteNumber,
3549            TrafficSignType::HighwayRouteNumber,
3550            TrafficSignType::HighwayInterchangeNumber,
3551            TrafficSignType::EuropeanRouteNumber,
3552            TrafficSignType::FederalHighwayDirectionLeft,
3553            TrafficSignType::FederalHighwayDirectionRight,
3554            TrafficSignType::PrimaryRoadDirectionLeft,
3555            TrafficSignType::PrimaryRoadDirectionRight,
3556            TrafficSignType::SecondaryRoadDirectionLeft,
3557            TrafficSignType::SecondaryRoadDirectionRight,
3558            TrafficSignType::DirectionDesignatedActorsLeft,
3559            TrafficSignType::DirectionDesignatedActorsRight,
3560            TrafficSignType::RoutingDesignatedActors,
3561            TrafficSignType::DirectionToHighwayLeft,
3562            TrafficSignType::DirectionToHighwayRight,
3563            TrafficSignType::DirectionToLocalDestinationLeft,
3564            TrafficSignType::DirectionToLocalDestinationRight,
3565            TrafficSignType::ConsolidatedDirections,
3566            TrafficSignType::StreetName,
3567            TrafficSignType::DirectionPreannouncement,
3568            TrafficSignType::DirectionPreannouncementLaneConfig,
3569            TrafficSignType::DirectionPreannouncementHighwayEntries,
3570            TrafficSignType::HighwayAnnouncement,
3571            TrafficSignType::OtherRoadAnnouncement,
3572            TrafficSignType::HighwayAnnouncementTruckStop,
3573            TrafficSignType::HighwayPreannouncementDirections,
3574            TrafficSignType::PoleExit,
3575            TrafficSignType::HighwayDistanceBoard,
3576            TrafficSignType::DetourLeft,
3577            TrafficSignType::DetourRight,
3578            TrafficSignType::NumberedDetour,
3579            TrafficSignType::DetourBegin,
3580            TrafficSignType::DetourEnd,
3581            TrafficSignType::DetourRoutingBoard,
3582            TrafficSignType::OptionalDetour,
3583            TrafficSignType::OptionalDetourRouting,
3584            TrafficSignType::RouteRecommendation,
3585            TrafficSignType::RouteRecommendationEnd,
3586            TrafficSignType::AnnounceLaneTransitionLeft,
3587            TrafficSignType::AnnounceLaneTransitionRight,
3588            TrafficSignType::AnnounceRightLaneEnd,
3589            TrafficSignType::AnnounceLeftLaneEnd,
3590            TrafficSignType::AnnounceRightLaneBegin,
3591            TrafficSignType::AnnounceLeftLaneBegin,
3592            TrafficSignType::AnnounceLaneConsolidation,
3593            TrafficSignType::DetourCityBlock,
3594            TrafficSignType::Gate,
3595            TrafficSignType::PoleWarning,
3596            TrafficSignType::TrafficCone,
3597            TrafficSignType::MobileLaneClosure,
3598            TrafficSignType::ReflectorPost,
3599            TrafficSignType::DirectionalBoardWarning,
3600            TrafficSignType::GuidingPlate,
3601            TrafficSignType::GuidingPlateWedges,
3602            TrafficSignType::ParkingHazard,
3603            TrafficSignType::TrafficLightGreenArrow,
3604            TrafficSignType::Text,
3605            TrafficSignType::Space,
3606            TrafficSignType::Time,
3607            TrafficSignType::Arrow,
3608            TrafficSignType::ConstrainedTo,
3609            TrafficSignType::Except,
3610            TrafficSignType::ValidForDistance,
3611            TrafficSignType::PriorityRoadBottomLeftFourWay,
3612            TrafficSignType::PriorityRoadTopLeftFourWay,
3613            TrafficSignType::PriorityRoadBottomLeftThreeWayStraight,
3614            TrafficSignType::PriorityRoadBottomLeftThreeWaySideways,
3615            TrafficSignType::PriorityRoadTopLeftThreeWayStraight,
3616            TrafficSignType::PriorityRoadBottomRightFourWay,
3617            TrafficSignType::PriorityRoadTopRightFourWay,
3618            TrafficSignType::PriorityRoadBottomRightThreeWayStraight,
3619            TrafficSignType::PriorityRoadBottomRightThreeWaySideway,
3620            TrafficSignType::PriorityRoadTopRightThreeWayStraight,
3621            TrafficSignType::ValidInDistance,
3622            TrafficSignType::StopIn,
3623            TrafficSignType::LeftArrow,
3624            TrafficSignType::LeftBendArrow,
3625            TrafficSignType::RightArrow,
3626            TrafficSignType::RightBendArrow,
3627            TrafficSignType::Accident,
3628            TrafficSignType::Snow,
3629            TrafficSignType::Fog,
3630            TrafficSignType::RollingHighwayInformation,
3631            TrafficSignType::Services,
3632            TrafficSignType::TimeRange,
3633            TrafficSignType::ParkingDiscTimeRestriction,
3634            TrafficSignType::Weight,
3635            TrafficSignType::Wet,
3636            TrafficSignType::ParkingConstraint,
3637            TrafficSignType::NoWaitingSideStripes,
3638            TrafficSignType::Rain,
3639            TrafficSignType::SnowRain,
3640            TrafficSignType::Night,
3641            TrafficSignType::Stop4Way,
3642            TrafficSignType::Truck,
3643            TrafficSignType::TractorsMayBePassed,
3644            TrafficSignType::Hazardous,
3645            TrafficSignType::Trailer,
3646            TrafficSignType::Zone,
3647            TrafficSignType::Motorcycle,
3648            TrafficSignType::MotorcycleAllowed,
3649            TrafficSignType::Car,
3650            TrafficSignType::EmergencyLane,
3651            TrafficSignType::Unknown,
3652        ];
3653
3654        for variant in variants {
3655            let cpp = traffic_control_device_type_to_cpp(&variant);
3656            let roundtrip = traffic_control_device_type_from_cpp(&cpp);
3657            assert_eq!(roundtrip, variant);
3658        }
3659    }
3660}