fundamentum_sdk_api/client/
api_version.rs

1//! Api versions
2//! More info: <https://dimonoff.atlassian.net/wiki/spaces/F2/pages/306273353781/Devices+API>
3
4/// Api V1.
5/// Test it here: <https://devices.fundamentum-iot-dev.com/api/v1/docs/>.
6#[derive(Debug, Clone, Copy)]
7#[deprecated(
8    since = "0.2.0",
9    note = "Use V2 or V3 instead of V1. V1 is deprecated."
10)]
11pub struct V1;
12
13/// Api V2.
14/// Test it here: <https://devices.fundamentum-iot-dev.com/api/v2/docs/>.
15#[derive(Debug, Clone, Copy)]
16pub struct V2;
17
18/// Api V3.
19/// Test it here: <https://devices.fundamentum-iot-dev.com/api/v3/docs/>.
20#[derive(Debug, Clone, Copy)]
21pub struct V3;
22
23/// Trait to get the version of the API.
24pub trait ApiVersion {
25    /// Get the version of the API.
26    fn version_str() -> &'static str;
27}
28
29impl ApiVersion for V2 {
30    fn version_str() -> &'static str {
31        "v2"
32    }
33}
34
35impl ApiVersion for V3 {
36    fn version_str() -> &'static str {
37        "v3"
38    }
39}
40
41#[cfg(test)]
42mod tests {
43    use super::*;
44
45    #[test]
46    fn test_v2_version() {
47        assert_eq!(V2::version_str(), "v2");
48    }
49
50    #[test]
51    fn test_v3_version() {
52        assert_eq!(V3::version_str(), "v3");
53    }
54}