1#![allow(non_upper_case_globals)]
2#![allow(non_camel_case_types)]
3#![allow(non_snake_case)]
4#![allow(dead_code)]
5
6use std::os::raw::{c_char, c_int, c_uint, c_void};
7
8#[repr(C)]
9#[derive(Copy, Clone)]
10pub struct napi_env__ {
11 _unused: [u8; 0],
12}
13
14pub type napi_env = *mut napi_env__;
16#[repr(C)]
17#[derive(Copy, Clone)]
18pub struct napi_value__ {
19 _unused: [u8; 0],
20}
21
22pub type napi_value = *mut napi_value__;
24#[repr(C)]
25#[derive(Copy, Clone)]
26pub struct napi_ref__ {
27 _unused: [u8; 0],
28}
29pub type napi_ref = *mut napi_ref__;
30#[repr(C)]
31#[derive(Copy, Clone)]
32pub struct napi_handle_scope__ {
33 _unused: [u8; 0],
34}
35pub type napi_handle_scope = *mut napi_handle_scope__;
36#[repr(C)]
37#[derive(Copy, Clone)]
38pub struct napi_escapable_handle_scope__ {
39 _unused: [u8; 0],
40}
41pub type napi_escapable_handle_scope = *mut napi_escapable_handle_scope__;
42#[repr(C)]
43#[derive(Copy, Clone)]
44pub struct napi_callback_info__ {
45 _unused: [u8; 0],
46}
47pub type napi_callback_info = *mut napi_callback_info__;
48#[repr(C)]
49#[derive(Copy, Clone)]
50pub struct napi_deferred__ {
51 _unused: [u8; 0],
52}
53#[repr(C)]
54#[derive(Copy, Clone)]
55pub struct uv_loop_s {
56 _unused: [u8; 0],
57}
58#[repr(C)]
59#[derive(Copy, Clone)]
60pub enum uv_run_mode {
61 UV_RUN_DEFAULT = 0,
62 UV_RUN_ONCE = 1,
63 UV_RUN_NOWAIT = 2,
64}
65pub type napi_deferred = *mut napi_deferred__;
66
67pub type napi_property_attributes = i32;
68
69pub mod PropertyAttributes {
70 use super::napi_property_attributes;
71
72 pub const default: napi_property_attributes = 0;
73 pub const writable: napi_property_attributes = 1 << 0;
74 pub const enumerable: napi_property_attributes = 1 << 1;
75 pub const configurable: napi_property_attributes = 1 << 2;
76
77 pub const static_: napi_property_attributes = 1 << 10;
80}
81
82pub type napi_valuetype = i32;
83
84pub mod ValueType {
85 pub const napi_undefined: i32 = 0;
86 pub const napi_null: i32 = 1;
87 pub const napi_boolean: i32 = 2;
88 pub const napi_number: i32 = 3;
89 pub const napi_string: i32 = 4;
90 pub const napi_symbol: i32 = 5;
91 pub const napi_object: i32 = 6;
92 pub const napi_function: i32 = 7;
93 pub const napi_external: i32 = 8;
94 #[cfg(feature = "napi6")]
95 pub const napi_bigint: i32 = 9;
96}
97
98pub type napi_typedarray_type = i32;
99
100pub mod TypedarrayType {
101 pub const int8_array: i32 = 0;
102 pub const uint8_array: i32 = 1;
103 pub const uint8_clamped_array: i32 = 2;
104 pub const int16_array: i32 = 3;
105 pub const uint16_array: i32 = 4;
106 pub const int32_array: i32 = 5;
107 pub const uint32_array: i32 = 6;
108 pub const float32_array: i32 = 7;
109 pub const float64_array: i32 = 8;
110 #[cfg(feature = "napi6")]
111 pub const bigint64_array: i32 = 9;
112 #[cfg(feature = "napi6")]
113 pub const biguint64_array: i32 = 10;
114}
115
116pub type napi_status = i32;
117
118pub mod Status {
119 pub const napi_ok: i32 = 0;
120 pub const napi_invalid_arg: i32 = 1;
121 pub const napi_object_expected: i32 = 2;
122 pub const napi_string_expected: i32 = 3;
123 pub const napi_name_expected: i32 = 4;
124 pub const napi_function_expected: i32 = 5;
125 pub const napi_number_expected: i32 = 6;
126 pub const napi_boolean_expected: i32 = 7;
127 pub const napi_array_expected: i32 = 8;
128 pub const napi_generic_failure: i32 = 9;
129 pub const napi_pending_exception: i32 = 10;
130 pub const napi_cancelled: i32 = 11;
131 pub const napi_escape_called_twice: i32 = 12;
132 pub const napi_handle_scope_mismatch: i32 = 13;
133 pub const napi_callback_scope_mismatch: i32 = 14;
134 pub const napi_queue_full: i32 = 15;
135 pub const napi_closing: i32 = 16;
136 pub const napi_bigint_expected: i32 = 17;
137 pub const napi_date_expected: i32 = 18;
138 pub const napi_arraybuffer_expected: i32 = 19;
139 pub const napi_detachable_arraybuffer_expected: i32 = 20;
140 pub const napi_would_deadlock: i32 = 21; pub const napi_no_external_buffers_allowed: i32 = 22;
142}
143
144pub type napi_callback =
145 Option<unsafe extern "C" fn(env: napi_env, info: napi_callback_info) -> napi_value>;
146pub type napi_finalize = Option<
147 unsafe extern "C" fn(env: napi_env, finalize_data: *mut c_void, finalize_hint: *mut c_void),
148>;
149#[repr(C)]
150#[derive(Copy, Clone, Debug)]
151pub struct napi_property_descriptor {
152 pub utf8name: *const c_char,
153 pub name: napi_value,
154 pub method: napi_callback,
155 pub getter: napi_callback,
156 pub setter: napi_callback,
157 pub value: napi_value,
158 pub attributes: napi_property_attributes,
159 pub data: *mut c_void,
160}
161
162#[repr(C)]
163#[derive(Copy, Clone)]
164pub struct napi_extended_error_info {
165 pub error_message: *const c_char,
166 pub engine_reserved: *mut c_void,
167 pub engine_error_code: u32,
168 pub error_code: napi_status,
169}
170
171#[cfg(feature = "napi6")]
172pub type napi_key_collection_mode = i32;
173
174#[cfg(feature = "napi6")]
175pub mod KeyCollectionMode {
176 pub use super::napi_key_collection_mode;
177 pub const include_prototypes: napi_key_collection_mode = 0;
178 pub const own_only: napi_key_collection_mode = 1;
179}
180
181#[cfg(feature = "napi6")]
182pub type napi_key_filter = i32;
183
184#[cfg(feature = "napi6")]
185pub mod KeyFilter {
186 use super::napi_key_filter;
187
188 pub const all_properties: napi_key_filter = 0;
189 pub const writable: napi_key_filter = 1;
190 pub const enumerable: napi_key_filter = 1 << 1;
191 pub const configurable: napi_key_filter = 1 << 2;
192 pub const skip_strings: napi_key_filter = 1 << 3;
193 pub const skip_symbols: napi_key_filter = 1 << 4;
194}
195
196#[cfg(feature = "napi6")]
197pub type napi_key_conversion = i32;
198
199#[cfg(feature = "napi6")]
200pub mod KeyConversion {
201 use super::napi_key_conversion;
202
203 pub const keep_numbers: napi_key_conversion = 0;
204 pub const numbers_to_strings: napi_key_conversion = 1;
205}
206#[cfg(feature = "napi8")]
207#[repr(C)]
208#[derive(Debug, Copy, Clone)]
209pub struct napi_async_cleanup_hook_handle__ {
210 _unused: [u8; 0],
211}
212#[cfg(feature = "napi8")]
213pub type napi_async_cleanup_hook_handle = *mut napi_async_cleanup_hook_handle__;
214#[cfg(feature = "napi8")]
215pub type napi_async_cleanup_hook =
216 Option<unsafe extern "C" fn(handle: napi_async_cleanup_hook_handle, data: *mut c_void)>;
217
218#[repr(C)]
219#[derive(Copy, Clone, Debug, PartialEq, Eq)]
220pub struct napi_type_tag {
221 pub lower: u64,
222 pub upper: u64,
223}
224
225#[repr(C)]
226#[derive(Copy, Clone)]
227pub struct napi_callback_scope__ {
228 _unused: [u8; 0],
229}
230pub type napi_callback_scope = *mut napi_callback_scope__;
231#[repr(C)]
232#[derive(Copy, Clone)]
233pub struct napi_async_context__ {
234 _unused: [u8; 0],
235}
236pub type napi_async_context = *mut napi_async_context__;
237#[repr(C)]
238#[derive(Copy, Clone)]
239pub struct napi_async_work__ {
240 _unused: [u8; 0],
241}
242pub type napi_async_work = *mut napi_async_work__;
243
244#[cfg(feature = "napi4")]
245#[repr(C)]
246#[derive(Copy, Clone)]
247pub struct napi_threadsafe_function__ {
248 _unused: [u8; 0],
249}
250
251#[cfg(feature = "napi4")]
252pub type napi_threadsafe_function = *mut napi_threadsafe_function__;
253
254#[cfg(feature = "napi4")]
255pub type napi_threadsafe_function_release_mode = i32;
256
257#[cfg(feature = "napi4")]
258pub mod ThreadsafeFunctionReleaseMode {
259 use super::napi_threadsafe_function_release_mode;
260 pub const release: napi_threadsafe_function_release_mode = 0;
261 pub const abort: napi_threadsafe_function_release_mode = 1;
262}
263
264#[cfg(feature = "napi4")]
265pub type napi_threadsafe_function_call_mode = i32;
266
267#[cfg(feature = "napi4")]
268pub mod ThreadsafeFunctionCallMode {
269 use super::napi_threadsafe_function_call_mode;
270
271 pub const nonblocking: napi_threadsafe_function_call_mode = 0;
272 pub const blocking: napi_threadsafe_function_call_mode = 1;
273}
274
275pub type napi_async_execute_callback =
276 Option<unsafe extern "C" fn(env: napi_env, data: *mut c_void)>;
277pub type napi_async_complete_callback =
278 Option<unsafe extern "C" fn(env: napi_env, status: napi_status, data: *mut c_void)>;
279
280#[cfg(feature = "napi4")]
281pub type napi_threadsafe_function_call_js = Option<
282 unsafe extern "C" fn(
283 env: napi_env,
284 js_callback: napi_value,
285 context: *mut c_void,
286 data: *mut c_void,
287 ),
288>;
289#[repr(C)]
290#[derive(Copy, Clone)]
291pub struct napi_node_version {
292 pub major: u32,
293 pub minor: u32,
294 pub patch: u32,
295 pub release: *const c_char,
296}
297
298pub type napi_addon_register_func =
299 Option<unsafe extern "C" fn(env: napi_env, exports: napi_value) -> napi_value>;
300#[repr(C)]
301#[derive(Copy, Clone)]
302pub struct napi_module {
303 pub nm_version: c_int,
304 pub nm_flags: c_uint,
305 pub nm_filename: *const c_char,
306 pub nm_register_func: napi_addon_register_func,
307 pub nm_modname: *const c_char,
308 pub nm_priv: *mut c_void,
309 pub reserved: [*mut c_void; 4usize],
310}
311
312#[cfg(feature = "napi10")]
313pub type node_api_basic_finalize = Option<
314 unsafe extern "C" fn(
315 env: node_api_basic_env,
316 finalize_data: *mut c_void,
317 finalize_hint: *mut c_void,
318 ),
319>;
320
321#[cfg(any(feature = "experimental", feature = "napi10"))]
322#[repr(C)]
323#[derive(Copy, Clone)]
324pub struct node_api_basic_env__ {
325 _unused: [u8; 0],
326}
327
328#[cfg(any(feature = "experimental", feature = "napi10"))]
329pub type node_api_basic_env = *mut node_api_basic_env__;