1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
//! Rust bindings to Fundamentum IoT MQTT *gRPC* IDL files.
//! A library that provides a Rust representation of the basic types, interfaces and
//! other components required to define and interact with the *gRPC* interface defined
//! by [`fundamentum-iot-mqtt-proto`][repo-proto].
//!
//! Current direct users:
//!
//! - [`fundamentum-edge-daemon`][repo-daemon]: the actual edge daemon server
//! implementation.
//!
//! [repo-proto]: https://bitbucket.org/amotus/fundamentum-iot-mqtt-proto
//! [repo-daemon]: https://bitbucket.org/amotus/fundamentum-edge-daemon
mod error;
pub use error::Error;
use std::{fmt::Display, str::FromStr};
/// The rust bindings generated from the protobuf files under `./proto/`.
///
/// Mirrors original protobuf top level 'com' namespace.
pub mod com {
/// Mirrors original protobuf namespace at 'com.fundamentum'.
///
/// Exposes Fundamentum related protobuf symbols.
pub mod fundamentum {
/// Mirrors original protobuf namespace at 'com.fundamentum.actions'.
///
/// Exposes Fundamentum's actions related protobuf symbols.
pub mod actions {
pub use v1 as latest;
/// Mirrors original protobuf namespace at 'com.fundamentum.actions.v1'.
///
/// Exposes Fundamentum's actions related protobuf symbols as of version 1
pub mod v1 {
use crate::Version;
include!(concat!(env!("OUT_DIR"), "/com.fundamentum.actions.v1.rs"));
/// Get current version
pub fn get_version() -> Version {
Version::V1
}
}
}
}
}
/// Protocol version
#[derive(Debug, Clone)]
pub enum Version {
V1,
}
impl FromStr for Version {
type Err = Error;
fn from_str(input: &str) -> Result<Version, Self::Err> {
match input {
"1" => Ok(Version::V1),
_ => Err(Error::InvalidVersion),
}
}
}
impl Display for Version {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
Version::V1 => write!(f, "1"),
}
}
}