From 6d57727cf63e9b3ae9fff81f61ed2db3cbcbf8bf Mon Sep 17 00:00:00 2001 From: Matthew D'Alonzo Date: Wed, 7 Aug 2024 10:57:23 -0400 Subject: [PATCH] Add SubscriptionInformation struct to usubscription * In uStreamer, there will be a SubscriptionCache that is used to locally track subscriptions coming in from the subscription service. We needed to create a data structure to track these subscriptions, which I have defined here. --- src/core/usubscription.rs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/core/usubscription.rs b/src/core/usubscription.rs index 77a9d62..3274a11 100644 --- a/src/core/usubscription.rs +++ b/src/core/usubscription.rs @@ -26,6 +26,41 @@ pub use crate::up_core_api::usubscription::{ use crate::{UStatus, UUri}; +// Tracks information for the SubscriptionCache +pub struct SubscriptionInformation { + pub topic: UUri, + pub subscriber: SubscriberInfo, + pub status: SubscriptionStatus, + pub attributes: SubscribeAttributes, + pub config: EventDeliveryConfig, +} + +impl Eq for SubscriptionInformation {} + +impl PartialEq for SubscriptionInformation { + fn eq(&self, other: &Self) -> bool { + self.subscriber == other.subscriber + } +} + +impl Hash for SubscriptionInformation { + fn hash(&self, state: &mut H) { + self.subscriber.hash(state); + } +} + +impl Clone for SubscriptionInformation { + fn clone(&self) -> Self { + Self { + topic: self.topic.clone(), + subscriber: self.subscriber.clone(), + status: self.status.clone(), + attributes: self.attributes.clone(), + config: self.config.clone(), + } + } +} + impl Hash for SubscriberInfo { /// Creates a hash value based on the URI property. ///