libits/lib.rs
1/*
2 * Software Name : libits-client
3 * SPDX-FileCopyrightText: Copyright (c) Orange SA
4 * SPDX-License-Identifier: MIT
5 *
6 * This software is distributed under the MIT license,
7 * see the "LICENSE.txt" file for more details or https://opensource.org/license/MIT/
8 *
9 * Authors: see CONTRIBUTORS.md
10 */
11
12//! Generic IoT3 messaging and telemetry for V2X
13//!
14//! MQTT
15//! ----
16//!
17//! Generic MQTT exchanges can be managed using both [MqttClient][1] to publish and subscribe and
18//! [MqttRouter][2] to handle messages using different callbacks depending the [Topic][3] a message is
19//! received on.
20//!
21//! If the `telemetry` feature is enabled:
22//! - message reception and publishing will be traced[^1]
23//! - the [W3C Context][4] will be injected as an MQTTv5 user property before publishing a message
24//!
25//! Telemetry
26//! ---------
27//!
28//! **Available with the `telemetry` feature**
29//!
30//! Provides functions to send traces to an OpenTelemetry collector
31//!
32//! V2X
33//! ---
34//!
35//! **Available with the `mobility` feature**
36//!
37//! Provides traits and functions to create applications that will listen to MQTT messages
38//!
39//! ### Geo routing
40//!
41//! **Available with the `geo_routing` feature**
42//!
43//! Provides topic management using queue system and quadkey positioning
44//!
45//! [^1]: For now, two traces are sent, but the aim is to send a single trace carrying (at least)
46//! two spans: one for reception and one for publishing
47//!
48//! [1]: transport::mqtt::mqtt_client::MqttClient
49//! [2]: transport::mqtt::mqtt_router::MqttRouter
50//! [3]: transport::mqtt::topic::Topic
51//! [4]: https://www.w3.org/TR/trace-context/
52
53use std::time::{SystemTime, UNIX_EPOCH};
54
55/// Client implementation and configuration
56///
57/// Provides structs to load configuration from file or bootstrap sequence and traits and functions
58/// to implement V2X application
59pub mod client;
60
61/// V2X and ETSI messages definition
62#[cfg(feature = "mobility")]
63pub mod exchange;
64
65/// Generic mobility structs and functions
66///
67/// Structs and helper functions to manipulate objects on a geodesic referential computing distance,
68/// bearing, ...
69///
70/// Everything here is using [SI units][1]
71///
72/// [1]: https://en.wikipedia.org/wiki/International_System_of_Units
73#[cfg(feature = "mobility")]
74pub mod mobility;
75
76#[cfg(feature = "mobility")]
77pub(crate) mod monitor;
78
79/// MQTT and Telemetry clients implementation
80pub mod transport;
81
82/// Returns the current UTC timestamp in milliseconds
83pub fn now() -> u64 {
84 SystemTime::now()
85 .duration_since(UNIX_EPOCH)
86 .unwrap()
87 .as_millis() as u64
88}