summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@ifm.com>2022-09-27 09:32:54 +0200
committerMatthias Beyer <matthias.beyer@ifm.com>2022-09-27 09:32:54 +0200
commit5d04affae76a1f3c7d0f7f232b7b59589c2c6bdf (patch)
tree78d14d89f82db5beeb2677fc9316607ff58893f9
parenta10d31bc0d95c2ce89d624db8e6ec0cb27632f10 (diff)
Add MessageType::eq_uuid()
This function can be used to compare two MessageType objects only by their UUID. The function returns true if and only if we have two MessageType objects that actually have a UUID and if that two UUIDs are equal to eachother. Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com>
-rw-r--r--crates/core/tedge_api/src/message.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/crates/core/tedge_api/src/message.rs b/crates/core/tedge_api/src/message.rs
index bbcda857..f7beb94c 100644
--- a/crates/core/tedge_api/src/message.rs
+++ b/crates/core/tedge_api/src/message.rs
@@ -141,6 +141,15 @@ impl MessageType {
pub fn name(&self) -> &'static str {
self.name
}
+
+ /// Check whether the UUID of this MessageType is the same as of the other MessageType
+ #[must_use]
+ pub fn eq_uuid(&self, other: &Self) -> bool {
+ match (&self.kind, &other.kind) {
+ (MessageKind::Typed(uuid_a), MessageKind::Typed(uuid_b)) => uuid_a == uuid_b,
+ _ => false,
+ }
+ }
}
/// A message to tell the core to stop thin-edge