File tree Expand file tree Collapse file tree 3 files changed +24
-7
lines changed
Expand file tree Collapse file tree 3 files changed +24
-7
lines changed Original file line number Diff line number Diff line change @@ -28,8 +28,8 @@ typedef struct libsql_stmt libsql_stmt;
2828typedef const libsql_database * libsql_database_t ;
2929
3030typedef struct {
31- uintptr_t frame_no ;
32- uintptr_t frames_synced ;
31+ int frame_no ;
32+ int frames_synced ;
3333} replicated ;
3434
3535typedef struct {
@@ -61,7 +61,9 @@ typedef struct {
6161extern "C" {
6262#endif // __cplusplus
6363
64- int libsql_sync (libsql_database_t db , replicated * out_replicated , const char * * out_err_msg );
64+ int libsql_sync (libsql_database_t db , const char * * out_err_msg );
65+
66+ int libsql_sync2 (libsql_database_t db , replicated * out_replicated , const char * * out_err_msg );
6567
6668int libsql_open_sync (const char * db_path ,
6769 const char * primary_url ,
Original file line number Diff line number Diff line change @@ -33,15 +33,30 @@ unsafe fn set_err_msg(msg: String, output: *mut *const std::ffi::c_char) {
3333
3434#[ no_mangle]
3535pub unsafe extern "C" fn libsql_sync (
36+ db : libsql_database_t ,
37+ out_err_msg : * mut * const std:: ffi:: c_char ,
38+ ) -> std:: ffi:: c_int {
39+ let db = db. get_ref ( ) ;
40+ match RT . block_on ( db. sync ( ) ) {
41+ Ok ( _) => 0 ,
42+ Err ( e) => {
43+ set_err_msg ( format ! ( "Error syncing database: {e}" ) , out_err_msg) ;
44+ 1
45+ }
46+ }
47+ }
48+
49+ #[ no_mangle]
50+ pub unsafe extern "C" fn libsql_sync2 (
3651 db : libsql_database_t ,
3752 out_replicated : * mut replicated ,
3853 out_err_msg : * mut * const std:: ffi:: c_char ,
3954) -> std:: ffi:: c_int {
4055 let db = db. get_ref ( ) ;
4156 match RT . block_on ( db. sync ( ) ) {
4257 Ok ( replicated) => {
43- ( * out_replicated) . frame_no = replicated. frame_no ( ) . unwrap_or ( 0 ) as usize ;
44- ( * out_replicated) . frames_synced = replicated. frames_synced ( ) as usize ;
58+ ( * out_replicated) . frame_no = replicated. frame_no ( ) . unwrap_or ( 0 ) as i32 ;
59+ ( * out_replicated) . frames_synced = replicated. frames_synced ( ) as i32 ;
4560 0
4661 }
4762 Err ( e) => {
Original file line number Diff line number Diff line change @@ -117,8 +117,8 @@ impl From<&mut libsql_connection> for libsql_connection_t {
117117
118118#[ repr( C ) ]
119119pub struct replicated {
120- pub frame_no : usize ,
121- pub frames_synced : usize ,
120+ pub frame_no : std :: ffi :: c_int ,
121+ pub frames_synced : std :: ffi :: c_int ,
122122}
123123
124124pub struct stmt {
You can’t perform that action at this time.
0 commit comments