@@ -12,13 +12,13 @@ use crate::sync::storage_adapter::StorageAdapter;
1212use crate :: sync:: subscriptions:: { StreamKey , apply_subscriptions} ;
1313use alloc:: borrow:: Cow ;
1414use alloc:: boxed:: Box ;
15- use alloc:: collections:: btree_map:: BTreeMap ;
1615use alloc:: rc:: Rc ;
1716use alloc:: { string:: String , vec:: Vec } ;
1817use powersync_sqlite_nostd:: bindings:: SQLITE_RESULT_SUBTYPE ;
1918use powersync_sqlite_nostd:: { self as sqlite, ColumnType } ;
2019use powersync_sqlite_nostd:: { Connection , Context } ;
2120use serde:: { Deserialize , Serialize } ;
21+ use serde_json:: value:: RawValue ;
2222use sqlite:: { ResultCode , Value } ;
2323
2424use 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
5948impl 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