@@ -66,34 +66,38 @@ pub enum ConcurrencyControl {
6666/// (probably by a pull replicator, or by application code on another thread)
6767/// since it was loaded into the CBLDocument being saved.
6868type ConflictHandler = fn ( & mut Document , & Document ) -> bool ;
69- #[ no_mangle]
69+ #[ unsafe ( no_mangle) ]
7070unsafe extern "C" fn c_conflict_handler (
7171 context : * mut :: std:: os:: raw:: c_void ,
7272 document_being_saved : * mut CBLDocument ,
7373 conflicting_document : * const CBLDocument ,
7474) -> bool {
75- let callback: ConflictHandler = std:: mem:: transmute ( context) ;
75+ unsafe {
76+ let callback: ConflictHandler = std:: mem:: transmute ( context) ;
7677
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+ }
8183}
8284
8385/// A document change listener lets you detect changes made to a specific document after they
8486/// are persisted to the database.
8587#[ deprecated( note = "please use `CollectionDocumentChangeListener` instead" ) ]
8688type DatabaseDocumentChangeListener = Box < dyn Fn ( & Database , Option < String > ) > ;
8789
88- #[ no_mangle]
90+ #[ unsafe ( no_mangle) ]
8991unsafe extern "C" fn c_database_document_change_listener (
9092 context : * mut :: std:: os:: raw:: c_void ,
9193 db : * const CBLDatabase ,
9294 c_doc_id : FLString ,
9395) {
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+ }
97101}
98102
99103//////// DATABASE'S DOCUMENT API:
@@ -308,15 +312,17 @@ impl Database {
308312/// are persisted to the collection.
309313type CollectionDocumentChangeListener = Box < dyn Fn ( Collection , Option < String > ) > ;
310314
311- #[ no_mangle]
315+ #[ unsafe ( no_mangle) ]
312316unsafe extern "C" fn c_collection_document_change_listener (
313317 context : * mut :: std:: os:: raw:: c_void ,
314318 change : * const CBLDocumentChange ,
315319) {
316320 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+ }
320326 }
321327}
322328
0 commit comments