webots/
distance_sensor_type.rs1use webots_bindings::{
2 WbDistanceSensorType_WB_DISTANCE_SENSOR_GENERIC,
3 WbDistanceSensorType_WB_DISTANCE_SENSOR_INFRA_RED,
4 WbDistanceSensorType_WB_DISTANCE_SENSOR_LASER, WbDistanceSensorType_WB_DISTANCE_SENSOR_SONAR,
5};
6
7pub enum DistanceSensorType {
8 Generic,
9 InfraLed,
10 Sonar,
11 Laser,
12}
13
14impl From<u32> for DistanceSensorType {
15 #[allow(non_upper_case_globals)]
16 fn from(other: u32) -> Self {
17 match other {
18 WbDistanceSensorType_WB_DISTANCE_SENSOR_GENERIC => DistanceSensorType::Generic,
19 WbDistanceSensorType_WB_DISTANCE_SENSOR_INFRA_RED => DistanceSensorType::InfraLed,
20 WbDistanceSensorType_WB_DISTANCE_SENSOR_SONAR => DistanceSensorType::Sonar,
21 WbDistanceSensorType_WB_DISTANCE_SENSOR_LASER => DistanceSensorType::Laser,
22 _ => unreachable!(),
23 }
24 }
25}
26
27impl Into<u32> for DistanceSensorType {
28 #[allow(non_upper_case_globals)]
29 fn into(self) -> u32 {
30 match self {
31 DistanceSensorType::Generic => WbDistanceSensorType_WB_DISTANCE_SENSOR_GENERIC,
32 DistanceSensorType::InfraLed => WbDistanceSensorType_WB_DISTANCE_SENSOR_INFRA_RED,
33 DistanceSensorType::Sonar => WbDistanceSensorType_WB_DISTANCE_SENSOR_SONAR,
34 DistanceSensorType::Laser => WbDistanceSensorType_WB_DISTANCE_SENSOR_LASER,
35 }
36 }
37}