diff --git a/rhio/src/network/sync.rs b/rhio/src/network/sync.rs index 847186a0..4efdc4f6 100644 --- a/rhio/src/network/sync.rs +++ b/rhio/src/network/sync.rs @@ -91,9 +91,7 @@ impl<'a> SyncProtocol<'a, Query> for RhioSyncProtocol { // // The current p2panda API does not give any control to turn off syncing for some data // stream subscriptions, this is why we're doing it this hacky way. - if matches!(query, Query::NoSyncSubject { .. }) - || matches!(query, Query::NoSyncBucket { .. }) - { + if query.is_no_sync() { debug!(parent: &span, "end sync session prematurely as we don't want to have one"); return Ok(()); } @@ -257,9 +255,7 @@ impl<'a> SyncProtocol<'a, Query> for RhioSyncProtocol { // // @TODO(adz): This is a workaround to disable syncing in some cases as the current p2panda // API does not give any control to turn off syncing for some topics. - if matches!(query, Query::NoSyncSubject { .. }) - || matches!(query, Query::NoSyncBucket { .. }) - { + if query.is_no_sync() { debug!(parent: &span, "end sync session prematurely as we don't want to have one"); return Ok(()); } diff --git a/rhio/src/topic.rs b/rhio/src/topic.rs index f4c576cf..677fb875 100644 --- a/rhio/src/topic.rs +++ b/rhio/src/topic.rs @@ -83,6 +83,13 @@ impl Query { } } + pub fn is_no_sync(&self) -> bool { + match self { + Self::NoSyncBucket { .. } | Self::NoSyncSubject { .. } => true, + _ => false, + } + } + fn prefix(&self) -> &str { match self { Self::Bucket { .. } => "bucket",