From d6fb1582ad7dc6634e0e2ff2f4d4b62e12f51c5c Mon Sep 17 00:00:00 2001 From: Daniel Krippner Date: Thu, 25 Jul 2024 12:15:03 +0200 Subject: [PATCH 1/5] Empty Authority field implies local UUri --- src/uri.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/uri.rs b/src/uri.rs index a91fefd..b5b9c15 100644 --- a/src/uri.rs +++ b/src/uri.rs @@ -389,7 +389,8 @@ impl UUri { self.eq(&UUri::default()) } - /// Check if an `UUri` is remote, by comparing authority fields. + /// Check if an `UUri` is remote, by comparing authority fields. UUris with empty authority are + /// considered to be local. /// /// # Returns /// @@ -406,7 +407,8 @@ impl UUri { /// assert!(authority_a.is_remote_authority(&authority_b)); /// ```` pub fn is_remote_authority(&self, other_uri: &UUri) -> bool { - self.authority_name != WILDCARD_AUTHORITY + !self.authority_name.is_empty() + && self.authority_name != WILDCARD_AUTHORITY && other_uri.authority_name != WILDCARD_AUTHORITY && self.authority_name != other_uri.authority_name } From 1b033c8794311abaeef6524165aa0b4a2bbcf93e Mon Sep 17 00:00:00 2001 From: Daniel Krippner Date: Fri, 26 Jul 2024 11:18:16 +0200 Subject: [PATCH 2/5] complement doctest --- src/uri.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/uri.rs b/src/uri.rs index b5b9c15..f2cdfff 100644 --- a/src/uri.rs +++ b/src/uri.rs @@ -405,6 +405,9 @@ impl UUri { /// let authority_a = UUri::from_str("up://Authority.A/100A/1/0").unwrap(); /// let authority_b = UUri::from_str("up://Authority.B/200B/2/20").unwrap(); /// assert!(authority_a.is_remote_authority(&authority_b)); + /// + /// let authority_local = UUri::from_str("up:///100A/1/0").unwrap(); + /// assert!(!authority_local.is_remote_authority(&authority_b)); /// ```` pub fn is_remote_authority(&self, other_uri: &UUri) -> bool { !self.authority_name.is_empty() From 898f42f8fc70ff279797b82d1c1168b5338f9798 Mon Sep 17 00:00:00 2001 From: Daniel Krippner Date: Fri, 26 Jul 2024 11:21:13 +0200 Subject: [PATCH 3/5] complement doctests more --- src/uri.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/uri.rs b/src/uri.rs index f2cdfff..bc1e96a 100644 --- a/src/uri.rs +++ b/src/uri.rs @@ -407,7 +407,12 @@ impl UUri { /// assert!(authority_a.is_remote_authority(&authority_b)); /// /// let authority_local = UUri::from_str("up:///100A/1/0").unwrap(); - /// assert!(!authority_local.is_remote_authority(&authority_b)); + /// assert!(!authority_local.is_remote_authority(&authority_a)); + /// + /// let authority_wildcard = UUri::from_str("up://*/100A/1/0").unwrap(); + /// assert!(!authority_local.is_remote_authority(&authority_a)); + /// assert!(!authority_a.is_remote_authority(&authority_wildcard)); + /// assert!(!authority_wildcard.is_remote_authority(&authority_wildcard)); /// ```` pub fn is_remote_authority(&self, other_uri: &UUri) -> bool { !self.authority_name.is_empty() From 42069e67512a0966f7986f0e519c94da49d31c15 Mon Sep 17 00:00:00 2001 From: Daniel Krippner Date: Fri, 26 Jul 2024 11:33:55 +0200 Subject: [PATCH 4/5] new-version clippy appeasement --- src/communication.rs | 2 +- src/umessage.rs | 2 +- src/uuid.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/communication.rs b/src/communication.rs index b62518d..3a37c1c 100644 --- a/src/communication.rs +++ b/src/communication.rs @@ -329,7 +329,7 @@ impl UPayload { /// # Errors /// /// * Err(`UMessageError`) if the unpacking process fails, for example if the payload could - /// not be deserialized into the target type `T`. + /// not be deserialized into the target type `T`. /// /// /// # Examples diff --git a/src/umessage.rs b/src/umessage.rs index b20b325..fe9a759 100644 --- a/src/umessage.rs +++ b/src/umessage.rs @@ -175,7 +175,7 @@ impl UMessage { /// # Errors /// /// * Err(`UMessageError`) if the unpacking process fails, for example if the payload could - /// not be deserialized into the target type `T`. + /// not be deserialized into the target type `T`. pub fn extract_protobuf(&self) -> Result { if let Some(payload) = &self.payload { let payload_format = self.attributes.payload_format.enum_value_or_default(); diff --git a/src/uuid.rs b/src/uuid.rs index d7872ce..4979471 100644 --- a/src/uuid.rs +++ b/src/uuid.rs @@ -302,7 +302,7 @@ impl FromStr for UUID { /// /// Returns an error /// * if the given string does not represent a UUID as defined by - /// [RFC 4122, Section 3](https://www.rfc-editor.org/rfc/rfc4122.html#section-3), or + /// [RFC 4122, Section 3](https://www.rfc-editor.org/rfc/rfc4122.html#section-3), or /// * if the bytes encoded in the string contain an invalid version and/or variant identifier. /// /// # Examples From 675587da3c4847f95c108905b2d2a043cb1142e1 Mon Sep 17 00:00:00 2001 From: Daniel Krippner Date: Fri, 26 Jul 2024 13:08:06 +0200 Subject: [PATCH 5/5] fix copy-paste redundancy --- src/uri.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uri.rs b/src/uri.rs index bc1e96a..8ca4460 100644 --- a/src/uri.rs +++ b/src/uri.rs @@ -410,7 +410,7 @@ impl UUri { /// assert!(!authority_local.is_remote_authority(&authority_a)); /// /// let authority_wildcard = UUri::from_str("up://*/100A/1/0").unwrap(); - /// assert!(!authority_local.is_remote_authority(&authority_a)); + /// assert!(!authority_wildcard.is_remote_authority(&authority_a)); /// assert!(!authority_a.is_remote_authority(&authority_wildcard)); /// assert!(!authority_wildcard.is_remote_authority(&authority_wildcard)); /// ````