Skip to content

Commit

Permalink
Add SubscriptionInformation struct to usubscription
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
matthewd0123 committed Aug 7, 2024
1 parent 9589ea8 commit 6d57727
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/core/usubscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<H: Hasher>(&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.
///
Expand Down

0 comments on commit 6d57727

Please sign in to comment.