@@ -66,34 +66,38 @@ pub enum ConcurrencyControl {
66
66
/// (probably by a pull replicator, or by application code on another thread)
67
67
/// since it was loaded into the CBLDocument being saved.
68
68
type ConflictHandler = fn ( & mut Document , & Document ) -> bool ;
69
- #[ no_mangle]
69
+ #[ unsafe ( no_mangle) ]
70
70
unsafe extern "C" fn c_conflict_handler (
71
71
context : * mut :: std:: os:: raw:: c_void ,
72
72
document_being_saved : * mut CBLDocument ,
73
73
conflicting_document : * const CBLDocument ,
74
74
) -> bool {
75
- let callback: ConflictHandler = std:: mem:: transmute ( context) ;
75
+ unsafe {
76
+ let callback: ConflictHandler = std:: mem:: transmute ( context) ;
76
77
77
- callback (
78
- & mut Document :: reference ( document_being_saved) ,
79
- & Document :: reference ( conflicting_document as * mut CBLDocument ) ,
80
- )
78
+ callback (
79
+ & mut Document :: reference ( document_being_saved) ,
80
+ & Document :: reference ( conflicting_document as * mut CBLDocument ) ,
81
+ )
82
+ }
81
83
}
82
84
83
85
/// A document change listener lets you detect changes made to a specific document after they
84
86
/// are persisted to the database.
85
87
#[ deprecated( note = "please use `CollectionDocumentChangeListener` instead" ) ]
86
88
type DatabaseDocumentChangeListener = Box < dyn Fn ( & Database , Option < String > ) > ;
87
89
88
- #[ no_mangle]
90
+ #[ unsafe ( no_mangle) ]
89
91
unsafe extern "C" fn c_database_document_change_listener (
90
92
context : * mut :: std:: os:: raw:: c_void ,
91
93
db : * const CBLDatabase ,
92
94
c_doc_id : FLString ,
93
95
) {
94
- let callback = context as * const DatabaseDocumentChangeListener ;
95
- let database = Database :: reference ( db as * mut CBLDatabase ) ;
96
- ( * callback) ( & database, c_doc_id. to_string ( ) ) ;
96
+ unsafe {
97
+ let callback = context as * const DatabaseDocumentChangeListener ;
98
+ let database = Database :: reference ( db as * mut CBLDatabase ) ;
99
+ ( * callback) ( & database, c_doc_id. to_string ( ) ) ;
100
+ }
97
101
}
98
102
99
103
//////// DATABASE'S DOCUMENT API:
@@ -308,15 +312,17 @@ impl Database {
308
312
/// are persisted to the collection.
309
313
type CollectionDocumentChangeListener = Box < dyn Fn ( Collection , Option < String > ) > ;
310
314
311
- #[ no_mangle]
315
+ #[ unsafe ( no_mangle) ]
312
316
unsafe extern "C" fn c_collection_document_change_listener (
313
317
context : * mut :: std:: os:: raw:: c_void ,
314
318
change : * const CBLDocumentChange ,
315
319
) {
316
320
let callback = context as * const CollectionDocumentChangeListener ;
317
- if let Some ( change) = change. as_ref ( ) {
318
- let collection = Collection :: reference ( change. collection as * mut CBLCollection ) ;
319
- ( * callback) ( collection, change. docID . to_string ( ) ) ;
321
+ unsafe {
322
+ if let Some ( change) = change. as_ref ( ) {
323
+ let collection = Collection :: reference ( change. collection as * mut CBLCollection ) ;
324
+ ( * callback) ( collection, change. docID . to_string ( ) ) ;
325
+ }
320
326
}
321
327
}
322
328
0 commit comments