Skip to content

Commit 4389aaf

Browse files
committed
Start with subscription logic
1 parent d6d513f commit 4389aaf

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

crates/core/src/sync/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pub mod line;
99
pub mod operations;
1010
pub mod storage_adapter;
1111
mod streaming_sync;
12+
mod subscriptions;
1213
mod sync_status;
1314

1415
pub use bucket_priority::BucketPriority;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
use core::time::Duration;
2+
3+
use alloc::string::String;
4+
use serde::Deserialize;
5+
use serde_with::{serde_as, DurationSeconds};
6+
7+
use crate::sync::BucketPriority;
8+
9+
/// A request sent from a PowerSync SDK to alter the subscriptions managed by this client.
10+
#[derive(Deserialize)]
11+
pub enum SubscriptionChangeRequest {
12+
Subscribe(SubscribeToStream),
13+
}
14+
15+
#[serde_as]
16+
#[derive(Deserialize)]
17+
pub struct SubscribeToStream {
18+
pub stream: String,
19+
pub params: Option<serde_json::value::RawValue>,
20+
#[serde_as(as = "Option<DurationSeconds>")]
21+
pub ttl: Option<Duration>,
22+
pub priority: Option<BucketPriority>,
23+
}
24+
25+
#[derive(Deserialize)]
26+
pub struct UnsubscribeFromStream {
27+
pub stream: String,
28+
pub params: Option<serde_json::value::RawValue>,
29+
pub immediate: bool,
30+
}

0 commit comments

Comments
 (0)