From 3d4ef8af4a12370ba914704d0032a5d99ceec5db Mon Sep 17 00:00:00 2001 From: Pete LeVasseur Date: Mon, 2 Dec 2024 17:55:08 -0500 Subject: [PATCH] Update up-rust to 0.3.0 and bump own version to prepare for release. * Use new functions for wildcard pieces of UUri --- Cargo.toml | 4 ++-- README.md | 2 +- src/lib.rs | 24 ++++++++++++------------ 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e5859a4..c3d99bb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,7 +31,7 @@ name = "up-transport-mqtt5" readme = "README.md" repository = "https://github.com/eclipse-uprotocol/up-client-mqtt5-rust" rust-version = "1.76" -version = "0.1.0" +version = "0.2.0" [dependencies] async-channel = {version = "1.6" } @@ -48,7 +48,7 @@ serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0" } tokio = { version = "1.38", features = ["full"] } tokio-macros = { version = "2.3" } -up-rust = "0.2.0" +up-rust = "0.3.0" url = { version = "2.5" } uuid = { version = "1.7", features = ["v8"] } diff --git a/README.md b/README.md index 7af0b04..15bacf2 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## Overview -This library implements a uTransport client for MQTT5 in Rust following the uProtocol [uTransport Specifications](https://github.com/eclipse-uprotocol/uprotocol-spec/blob/main/up-l1/README.adoc). +This library implements a uTransport client for [MQTT5](https://github.com/eclipse-uprotocol/up-spec/blob/v1.6.0-alpha.4/up-l1/mqtt_5.adoc) in Rust following the uProtocol [uTransport Specifications](https://github.com/eclipse-uprotocol/uprotocol-spec/blob/main/up-l1/README.adoc) for spec version 1.6.0-alpha.4. ## Getting Started diff --git a/src/lib.rs b/src/lib.rs index 1e36caf..4d82a18 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -34,13 +34,6 @@ use up_rust::{ pub mod transport; -// URI Wildcard consts -// TODO: Remove once up-rust contains/exposes these values -const WILDCARD_AUTHORITY: &str = "*"; -const WILDCARD_ENTITY_ID: u32 = 0x0000_FFFF; -const WILDCARD_ENTITY_VERSION: u32 = 0x0000_00FF; -const WILDCARD_RESOURCE_ID: u32 = 0x0000_FFFF; - // Attribute field names const UURI_NAME: &str = "uuri"; const UUID_NAME: &str = "uuid"; @@ -915,27 +908,27 @@ impl UPClientMqtt { /// # Arguments /// * `uri` - UUri to convert to mqtt topic segment. fn uri_to_mqtt_topic_segment(&self, uri: &UUri) -> String { - let authority = if uri.authority_name.is_empty() { + let authority = if uri.has_empty_authority() { &self.authority_name - } else if uri.authority_name == WILDCARD_AUTHORITY { + } else if uri.has_wildcard_authority() { "+" } else { &uri.authority_name }; - let ue_id = if uri.ue_id == WILDCARD_ENTITY_ID { + let ue_id = if uri.has_wildcard_entity_type() { "+".into() } else { format!("{:X}", uri.ue_id) }; - let ue_ver = if uri.ue_version_major == WILDCARD_ENTITY_VERSION { + let ue_ver = if uri.has_wildcard_version() { "+".into() } else { format!("{:X}", uri.ue_version_major) }; - let res_id = if uri.resource_id == WILDCARD_RESOURCE_ID { + let res_id = if uri.has_wildcard_resource_id() { "+".into() } else { format!("{:X}", uri.resource_id) @@ -970,6 +963,13 @@ mod tests { use super::*; + // URI Wildcard consts + // TODO: Remove once up-rust contains/exposes these values + const WILDCARD_AUTHORITY: &str = "*"; + const WILDCARD_ENTITY_ID: u32 = 0x0000_FFFF; + const WILDCARD_ENTITY_VERSION: u32 = 0x0000_00FF; + const WILDCARD_RESOURCE_ID: u32 = 0x0000_FFFF; + /// Constants defining the protobuf field numbers for UAttributes. pub const ID_NUM: &str = "1"; pub const TYPE_NUM: &str = "2";