File tree Expand file tree Collapse file tree 3 files changed +27
-7
lines changed Expand file tree Collapse file tree 3 files changed +27
-7
lines changed Original file line number Diff line number Diff line change @@ -28,8 +28,8 @@ typedef struct libsql_stmt libsql_stmt;
28
28
typedef const libsql_database * libsql_database_t ;
29
29
30
30
typedef struct {
31
- uintptr_t frame_no ;
32
- uintptr_t frames_synced ;
31
+ int frame_no ;
32
+ int frames_synced ;
33
33
} replicated ;
34
34
35
35
typedef struct {
@@ -61,7 +61,9 @@ typedef struct {
61
61
extern "C" {
62
62
#endif // __cplusplus
63
63
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 );
65
67
66
68
int libsql_open_sync (const char * db_path ,
67
69
const char * primary_url ,
Original file line number Diff line number Diff line change @@ -33,15 +33,33 @@ unsafe fn set_err_msg(msg: String, output: *mut *const std::ffi::c_char) {
33
33
34
34
#[ no_mangle]
35
35
pub 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 (
36
51
db : libsql_database_t ,
37
52
out_replicated : * mut replicated ,
38
53
out_err_msg : * mut * const std:: ffi:: c_char ,
39
54
) -> std:: ffi:: c_int {
40
55
let db = db. get_ref ( ) ;
41
56
match RT . block_on ( db. sync ( ) ) {
42
57
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
+ if !out_replicated. is_null ( ) {
59
+ ( * out_replicated) . frame_no = replicated. frame_no ( ) . unwrap_or ( 0 ) as i32 ;
60
+ ( * out_replicated) . frames_synced = replicated. frames_synced ( ) as i32 ;
61
+ }
62
+
45
63
0
46
64
}
47
65
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 {
117
117
118
118
#[ repr( C ) ]
119
119
pub 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 ,
122
122
}
123
123
124
124
pub struct stmt {
You can’t perform that action at this time.
0 commit comments