Skip to content

Commit fda59fd

Browse files
committed
Use raw json value
1 parent 8115037 commit fda59fd

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

crates/core/src/sync/interface.rs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ use crate::sync::storage_adapter::StorageAdapter;
1212
use crate::sync::subscriptions::{StreamKey, apply_subscriptions};
1313
use alloc::borrow::Cow;
1414
use alloc::boxed::Box;
15-
use alloc::collections::btree_map::BTreeMap;
1615
use alloc::rc::Rc;
1716
use alloc::{string::String, vec::Vec};
1817
use powersync_sqlite_nostd::bindings::SQLITE_RESULT_SUBTYPE;
1918
use powersync_sqlite_nostd::{self as sqlite, ColumnType};
2019
use powersync_sqlite_nostd::{Connection, Context};
2120
use serde::{Deserialize, Serialize};
21+
use serde_json::value::RawValue;
2222
use sqlite::{ResultCode, Value};
2323

2424
use crate::sync::BucketPriority;
@@ -41,19 +41,8 @@ pub struct StartSyncStream {
4141
/// We will increase the expiry date for those streams at the time we connect and disconnect.
4242
#[serde(default)]
4343
pub active_streams: Rc<Vec<StreamKey>>,
44-
/// Application metadata to include in the request when opening a sync stream.
45-
///
46-
/// This should only contain a JSON map of strings.
47-
///
48-
/// We use `BTreeMap<String, String>` instead of `serde_json::Map<String, serde_json::Value>`
49-
/// (like `parameters` uses) because:
50-
/// 1. It enforces type safety at compile time - values must be strings, not arbitrary JSON
51-
/// 2. It requires no runtime validation to ensure values are strings
52-
/// 3. It serializes to the same JSON format (a map with string values)
53-
/// 4. `serde_json::Map<String, String>` doesn't implement `Serialize`/`Deserialize` - the
54-
/// `serde_json::Map` type only supports `serde_json::Value` as the value type, not `String`
5544
#[serde(default)]
56-
pub app_metadata: Option<BTreeMap<String, String>>,
45+
pub app_metadata: Option<Box<RawValue>>,
5746
}
5847

5948
impl StartSyncStream {
@@ -175,7 +164,7 @@ pub struct StreamingSyncRequest {
175164
pub parameters: Option<serde_json::Map<String, serde_json::Value>>,
176165
pub streams: Rc<StreamSubscriptionRequest>,
177166
#[serde(skip_serializing_if = "Option::is_none")]
178-
pub app_metadata: Option<BTreeMap<String, String>>,
167+
pub app_metadata: Option<Box<RawValue>>,
179168
}
180169

181170
#[derive(Debug, Serialize, PartialEq)]

0 commit comments

Comments
 (0)