11#![ deny( unsafe_op_in_unsafe_fn) ]
22
33use arrow_array:: UInt8Array ;
4- use dora_node_api:: { arrow :: array :: AsArray , DoraNode , Event , EventStream } ;
4+ use dora_node_api:: { DoraNode , Event , EventStream , arrow :: array :: AsArray } ;
55use eyre:: Context ;
66use std:: { ffi:: c_void, ptr, slice} ;
77
@@ -21,7 +21,7 @@ struct DoraContext {
2121/// needed, use the [`free_dora_context`] function.
2222///
2323/// On error, a null pointer is returned.
24- #[ no_mangle]
24+ #[ unsafe ( no_mangle) ]
2525pub extern "C" fn init_dora_context_from_env ( ) -> * mut c_void {
2626 let context = || {
2727 let ( node, events) = DoraNode :: init_from_env ( ) ?;
@@ -47,7 +47,7 @@ pub extern "C" fn init_dora_context_from_env() -> *mut c_void {
4747/// Only pointers created through [`init_dora_context_from_env`] are allowed
4848/// as arguments. Each context pointer must be freed exactly once. After
4949/// freeing, the pointer must not be used anymore.
50- #[ no_mangle]
50+ #[ unsafe ( no_mangle) ]
5151pub unsafe extern "C" fn free_dora_context ( context : * mut c_void ) {
5252 let context: Box < DoraContext > = unsafe { Box :: from_raw ( context. cast ( ) ) } ;
5353 // drop all fields except for `node`
@@ -71,7 +71,7 @@ pub unsafe extern "C" fn free_dora_context(context: *mut c_void) {
7171/// The `context` argument must be a dora context created through
7272/// [`init_dora_context_from_env`]. The context must be still valid, i.e., not
7373/// freed yet.
74- #[ no_mangle]
74+ #[ unsafe ( no_mangle) ]
7575pub unsafe extern "C" fn dora_next_event ( context : * mut c_void ) -> * mut c_void {
7676 let context: & mut DoraContext = unsafe { & mut * context. cast ( ) } ;
7777 match context. events . recv ( ) {
@@ -87,7 +87,7 @@ pub unsafe extern "C" fn dora_next_event(context: *mut c_void) -> *mut c_void {
8787/// The `event` argument must be a dora event received through
8888/// [`dora_next_event`]. The event must be still valid, i.e., not
8989/// freed yet.
90- #[ no_mangle]
90+ #[ unsafe ( no_mangle) ]
9191pub unsafe extern "C" fn read_dora_event_type ( event : * const ( ) ) -> EventType {
9292 let event: & Event = unsafe { & * event. cast ( ) } ;
9393 match event {
@@ -125,7 +125,7 @@ pub enum EventType {
125125///
126126/// - Note: `Out_ptr` is not a null-terminated string. The length of the string
127127/// is given by `out_len`.
128- #[ no_mangle]
128+ #[ unsafe ( no_mangle) ]
129129pub unsafe extern "C" fn read_dora_input_id (
130130 event : * const ( ) ,
131131 out_ptr : * mut * const u8 ,
@@ -165,7 +165,7 @@ pub unsafe extern "C" fn read_dora_input_id(
165165/// freed yet. The returned `out_ptr` must not be used after
166166/// freeing the `event`, since it points directly into the event's
167167/// memory.
168- #[ no_mangle]
168+ #[ unsafe ( no_mangle) ]
169169pub unsafe extern "C" fn read_dora_input_data (
170170 event : * const ( ) ,
171171 out_ptr : * mut * const u8 ,
@@ -203,7 +203,7 @@ pub unsafe extern "C" fn read_dora_input_data(
203203/// ## Safety
204204///
205205/// Return `0` if the given event is not an input event.
206- #[ no_mangle]
206+ #[ unsafe ( no_mangle) ]
207207pub unsafe extern "C" fn read_dora_input_timestamp ( event : * const ( ) ) -> core:: ffi:: c_ulonglong {
208208 let event: & Event = unsafe { & * event. cast ( ) } ;
209209 match event {
@@ -221,7 +221,7 @@ pub unsafe extern "C" fn read_dora_input_timestamp(event: *const ()) -> core::ff
221221/// freeing, the pointer and all derived pointers must not be used anymore.
222222/// This also applies to the `read_dora_event_*` functions, which return
223223/// pointers into the original event structure.
224- #[ no_mangle]
224+ #[ unsafe ( no_mangle) ]
225225pub unsafe extern "C" fn free_dora_event ( event : * mut c_void ) {
226226 let _: Box < Event > = unsafe { Box :: from_raw ( event. cast ( ) ) } ;
227227}
@@ -241,7 +241,7 @@ pub unsafe extern "C" fn free_dora_event(event: *mut c_void) {
241241/// UTF8-encoded string.
242242/// - The `data_ptr` and `data_len` fields must be the start pointer and length
243243/// a byte array.
244- #[ no_mangle]
244+ #[ unsafe ( no_mangle) ]
245245pub unsafe extern "C" fn dora_send_output (
246246 context : * mut c_void ,
247247 id_ptr : * const u8 ,
0 commit comments