@@ -8,7 +8,6 @@ use glib::subclass::{Signal, prelude::*};
88use glib:: { Properties , clone} ;
99pub use hex:: FromHexError ;
1010use loro:: { ExportMode , LoroDoc , LoroText , event:: Diff } ;
11- use p2panda_core:: cbor:: { decode_cbor, encode_cbor} ;
1211use p2panda_core:: { self , Topic } ;
1312use reflection_node:: { TopicStream , TopicSubscription , TopicSubscriptionError } ;
1413use tracing:: error;
@@ -98,14 +97,9 @@ impl DocumentId {
9897}
9998
10099#[ derive( Debug , serde:: Serialize , serde:: Deserialize ) ]
101- #[ serde( tag = "t" , content = "d" ) ]
102100enum EphemeralData {
103- #[ serde( rename = "cursor" ) ]
104101 Cursor {
105- #[ serde( rename = "i" ) ]
106102 insert_cursor : Option < loro:: cursor:: Cursor > ,
107-
108- #[ serde( rename = "s" ) ]
109103 selection_bound : Option < loro:: cursor:: Cursor > ,
110104 } ,
111105}
@@ -290,17 +284,17 @@ mod imp {
290284 * self . insert_cursor . write ( ) . unwrap ( ) = insert_cursor;
291285
292286 if send {
293- self . brodcast_ephemeral ( ) ;
287+ self . broadcast_ephemeral ( ) ;
294288 }
295289 }
296290
297- pub fn brodcast_ephemeral ( & self ) {
291+ pub fn broadcast_ephemeral ( & self ) {
298292 let cursor_data = EphemeralData :: Cursor {
299293 insert_cursor : self . insert_cursor . read ( ) . unwrap ( ) . clone ( ) ,
300294 selection_bound : self . selection_bound . read ( ) . unwrap ( ) . clone ( ) ,
301295 } ;
302296
303- let cursor_bytes = match encode_cbor ( & cursor_data) {
297+ let cursor_bytes = match postcard :: to_allocvec ( & cursor_data) {
304298 Ok ( data) => data,
305299 Err ( error) => {
306300 error ! ( "Failed to serialize cursor: {}" , error) ;
@@ -943,7 +937,7 @@ impl TopicSubscription for DocumentHandle {
943937 let author = document. authors ( ) . add ( VerifyingKey ( author) ) ;
944938 author. set_online ( true ) ;
945939 // When a new author joins we need to send ephemeral messages again
946- document. imp ( ) . brodcast_ephemeral ( ) ;
940+ document. imp ( ) . broadcast_ephemeral ( ) ;
947941 } ) ;
948942 }
949943 }
@@ -967,7 +961,7 @@ impl TopicSubscription for DocumentHandle {
967961 ) {
968962 if let Some ( document) = self . 0 . upgrade ( ) {
969963 document. main_context ( ) . invoke ( move || {
970- if let Ok ( data) = decode_cbor ( & data[ ..] )
964+ if let Ok ( data) = postcard :: from_bytes ( & data[ ..] )
971965 && let Some ( author) = document. authors ( ) . author ( & VerifyingKey ( author) )
972966 {
973967 document
0 commit comments