@@ -9,11 +9,9 @@ use glib::{Properties, clone};
99pub use hex:: FromHexError ;
1010use loro:: { ExportMode , LoroDoc , LoroText , event:: Diff } ;
1111use p2panda_core:: cbor:: { decode_cbor, encode_cbor} ;
12- use reflection_node:: p2panda_core;
13- use reflection_node:: topic:: {
14- SubscribableTopic , Subscription as TopicSubscription ,
15- SubscriptionError as TopicSubscriptionError ,
16- } ;
12+ use p2panda_core:: { self , Topic } ;
13+ use reflection_node:: subscription:: Subscription as TopicSubscription ;
14+ use reflection_node:: traits:: { SubscribableTopic , SubscriptionError as TopicSubscriptionError } ;
1715use tracing:: error;
1816
1917use crate :: author:: Author ;
@@ -37,6 +35,18 @@ impl From<[u8; 32]> for DocumentId {
3735 }
3836}
3937
38+ impl From < Topic > for DocumentId {
39+ fn from ( value : Topic ) -> Self {
40+ Self ( value. to_bytes ( ) )
41+ }
42+ }
43+
44+ impl From < DocumentId > for Topic {
45+ fn from ( value : DocumentId ) -> Self {
46+ Topic :: from ( value. 0 )
47+ }
48+ }
49+
4050impl fmt:: Display for DocumentId {
4151 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
4252 f. write_str ( & self . to_hex ( ) )
@@ -298,7 +308,7 @@ mod imp {
298308 #[ weak]
299309 subscription,
300310 async move {
301- if let Err ( error) = subscription. send_ephemeral ( cursor_bytes) . await {
311+ if let Err ( error) = subscription. publish_ephemeral ( cursor_bytes) . await {
302312 error!( "Failed to send cursor position: {}" , error) ;
303313 }
304314 }
@@ -495,7 +505,7 @@ mod imp {
495505 subscription,
496506 async move {
497507 // Broadcast a "text delta" to all peers
498- if let Err ( error) = subscription. send_delta ( delta_bytes) . await {
508+ if let Err ( error) = subscription. publish_delta ( delta_bytes) . await {
499509 error!(
500510 "Failed to send delta of document to the network: {}" ,
501511 error
@@ -828,7 +838,7 @@ impl Document {
828838 . export ( ExportMode :: Snapshot )
829839 . expect ( "encoded crdt snapshot" ) ;
830840
831- if let Err ( error) = subscription. send_snapshot ( snapshot_bytes) . await {
841+ if let Err ( error) = subscription. publish_snapshot ( snapshot_bytes) . await {
832842 error ! (
833843 "Failed to send snapshot of document to the network: {}" ,
834844 error
@@ -872,7 +882,7 @@ impl Document {
872882 . expect ( "crdt_doc to be set" )
873883 . export ( ExportMode :: Snapshot )
874884 . expect ( "encoded crdt snapshot" ) ;
875- if let Err ( error) = subscription. send_snapshot ( snapshot_bytes) . await {
885+ if let Err ( error) = subscription. publish_snapshot ( snapshot_bytes) . await {
876886 error ! (
877887 "Failed to send snapshot of document to the network: {}" ,
878888 error
0 commit comments