waze_rs/
helpers.rs

1use crate::waze_route_calculator::WazeRouteCalculator;
2use crate::waze_structs::WazeAddressCoordinates;
3
4/// Enum representing the region of the Waze server.
5#[derive(Copy, Clone, Debug)]
6pub enum Region {
7    /// United States
8    US = 0,
9
10    /// Europe
11    EU,
12
13    /// Israel
14    IL,
15
16    /// Australia
17    AU,
18}
19
20/// Enum representing the vehicle type.
21#[derive(Copy, Clone, Debug, PartialEq)]
22pub enum VehicleType {
23    /// Regular Car
24    CAR,
25
26    /// Taxi
27    TAXI,
28
29    /// Motorcycle
30    MOTORCYCLE,
31}
32
33impl VehicleType {
34    /// Converts the `VehicleType` enum to a string slice.
35    ///
36    /// # Returns
37    /// * A string slice representing the vehicle type.
38    pub fn to_string(&self) -> &str {
39        match self {
40            VehicleType::CAR => "",
41            VehicleType::TAXI => "TAXI",
42            VehicleType::MOTORCYCLE => "MOTORCYCLE",
43        }
44    }
45}
46impl WazeRouteCalculator {
47    /// Base Waze URL
48    pub const WAZE_URL: &'static str = "https://www.waze.com/";
49
50    /// Base Coordinates for each region
51    pub(crate) const BASE_COORDS: [(Region, WazeAddressCoordinates); 4] = [
52        (
53            Region::US,
54            WazeAddressCoordinates {
55                lat: 40.713,
56                lon: -74.006,
57            },
58        ),
59        (
60            Region::EU,
61            WazeAddressCoordinates {
62                lat: 47.498,
63                lon: 19.040,
64            },
65        ),
66        (
67            Region::IL,
68            WazeAddressCoordinates {
69                lat: 31.768,
70                lon: 35.214,
71            },
72        ),
73        (
74            Region::AU,
75            WazeAddressCoordinates {
76                lat: -35.281,
77                lon: 149.128,
78            },
79        ),
80    ];
81
82    /// Waze  servers path for each region
83    pub(crate) const COORD_SERVERS: [(Region, &'static str); 4] = [
84        (Region::US, "SearchServer/mozi"),
85        (Region::EU, "row-SearchServer/mozi"),
86        (Region::IL, "il-SearchServer/mozi"),
87        (Region::AU, "row-SearchServer/mozi"),
88    ];
89
90    /// Waze routing servers path for each region
91    pub(crate) const ROUTING_SERVERS: [(Region, &'static str); 4] = [
92        (Region::US, "RoutingManager/routingRequest"),
93        (Region::EU, "row-RoutingManager/routingRequest"),
94        (Region::IL, "il-RoutingManager/routingRequest"),
95        (Region::AU, "row-RoutingManager/routingRequest"),
96    ];
97}