ohos_sys/napi/napi_ffi.rs
1// automatically generated by rust-bindgen 0.71.1
2
3#![allow(non_upper_case_globals)]
4#![allow(non_camel_case_types)]
5#![allow(non_snake_case)]
6pub use ohos_sys_opaque_types::{napi_env, napi_value};
7
8pub const NAPI_VERSION: u32 = 8;
9pub const NAPI_VERSION_EXPERIMENTAL: u32 = 2147483647;
10pub const NAPI_AUTO_LENGTH: i32 = -1;
11pub const NAPI_MODULE_VERSION: u32 = 1;
12impl napi_qos_t {
13 pub const napi_qos_background: napi_qos_t = napi_qos_t(0);
14 pub const napi_qos_utility: napi_qos_t = napi_qos_t(1);
15 pub const napi_qos_default: napi_qos_t = napi_qos_t(2);
16 pub const napi_qos_user_initiated: napi_qos_t = napi_qos_t(3);
17}
18#[repr(transparent)]
19#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
20pub struct napi_qos_t(pub ::core::ffi::c_uint);
21#[cfg(feature = "api-12")]
22#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
23impl napi_event_mode {
24 /// In this mode, the current asynchronous thread will be blocked and events of native event loop will
25 /// be processed.
26 pub const napi_event_mode_default: napi_event_mode = napi_event_mode(0);
27 /// In this mode, the current asynchronous thread will not be blocked. If there are events in the event loop,
28 /// only one event will be processed and then the event loop will stop. If there are no events in the loop,
29 /// the event loop will stop immediately.
30 pub const napi_event_mode_nowait: napi_event_mode = napi_event_mode(1);
31}
32#[repr(transparent)]
33/// Indicates the running mode of the native event loop in an asynchronous native thread.
34///
35///
36/// Available since API-level: 12
37#[cfg(feature = "api-12")]
38#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
39#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
40pub struct napi_event_mode(pub ::core::ffi::c_uint);
41#[cfg(feature = "api-12")]
42#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
43impl napi_task_priority {
44 /// The immediate priority tasks should be promptly processed whenever feasible.
45 pub const napi_priority_immediate: napi_task_priority = napi_task_priority(0);
46 /// The high priority tasks, as sorted by their handle time, should be prioritized over tasks with low priority.
47 pub const napi_priority_high: napi_task_priority = napi_task_priority(1);
48 /// The low priority tasks, as sorted by their handle time, should be processed before idle priority tasks.
49 pub const napi_priority_low: napi_task_priority = napi_task_priority(2);
50 /// The idle priority tasks should be processed immediately only if there are no other priority tasks.
51 pub const napi_priority_idle: napi_task_priority = napi_task_priority(3);
52}
53#[repr(transparent)]
54/// Indicates the priority of a task dispatched from native thread to ArkTS thread.
55///
56///
57/// Available since API-level: 12
58#[cfg(feature = "api-12")]
59#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
60#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
61pub struct napi_task_priority(pub ::core::ffi::c_uint);
62pub type char16_t = u16;
63#[repr(C)]
64pub struct napi_ref__ {
65 _unused: [u8; 0],
66}
67pub type napi_ref = *mut napi_ref__;
68#[repr(C)]
69pub struct napi_handle_scope__ {
70 _unused: [u8; 0],
71}
72pub type napi_handle_scope = *mut napi_handle_scope__;
73#[repr(C)]
74pub struct napi_escapable_handle_scope__ {
75 _unused: [u8; 0],
76}
77pub type napi_escapable_handle_scope = *mut napi_escapable_handle_scope__;
78#[repr(C)]
79pub struct napi_callback_info__ {
80 _unused: [u8; 0],
81}
82pub type napi_callback_info = *mut napi_callback_info__;
83#[repr(C)]
84pub struct napi_deferred__ {
85 _unused: [u8; 0],
86}
87pub type napi_deferred = *mut napi_deferred__;
88impl napi_property_attributes {
89 pub const napi_default: napi_property_attributes = napi_property_attributes(0);
90 pub const napi_writable: napi_property_attributes = napi_property_attributes(1);
91 pub const napi_enumerable: napi_property_attributes = napi_property_attributes(2);
92 pub const napi_configurable: napi_property_attributes = napi_property_attributes(4);
93 pub const napi_static: napi_property_attributes = napi_property_attributes(1024);
94 pub const napi_default_method: napi_property_attributes = napi_property_attributes(5);
95 pub const napi_default_jsproperty: napi_property_attributes = napi_property_attributes(7);
96}
97#[repr(transparent)]
98#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
99pub struct napi_property_attributes(pub ::core::ffi::c_uint);
100impl napi_valuetype {
101 pub const napi_undefined: napi_valuetype = napi_valuetype(0);
102 pub const napi_null: napi_valuetype = napi_valuetype(1);
103 pub const napi_boolean: napi_valuetype = napi_valuetype(2);
104 pub const napi_number: napi_valuetype = napi_valuetype(3);
105 pub const napi_string: napi_valuetype = napi_valuetype(4);
106 pub const napi_symbol: napi_valuetype = napi_valuetype(5);
107 pub const napi_object: napi_valuetype = napi_valuetype(6);
108 pub const napi_function: napi_valuetype = napi_valuetype(7);
109 pub const napi_external: napi_valuetype = napi_valuetype(8);
110 pub const napi_bigint: napi_valuetype = napi_valuetype(9);
111}
112#[repr(transparent)]
113#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
114pub struct napi_valuetype(pub ::core::ffi::c_uint);
115impl napi_typedarray_type {
116 pub const napi_int8_array: napi_typedarray_type = napi_typedarray_type(0);
117 pub const napi_uint8_array: napi_typedarray_type = napi_typedarray_type(1);
118 pub const napi_uint8_clamped_array: napi_typedarray_type = napi_typedarray_type(2);
119 pub const napi_int16_array: napi_typedarray_type = napi_typedarray_type(3);
120 pub const napi_uint16_array: napi_typedarray_type = napi_typedarray_type(4);
121 pub const napi_int32_array: napi_typedarray_type = napi_typedarray_type(5);
122 pub const napi_uint32_array: napi_typedarray_type = napi_typedarray_type(6);
123 pub const napi_float32_array: napi_typedarray_type = napi_typedarray_type(7);
124 pub const napi_float64_array: napi_typedarray_type = napi_typedarray_type(8);
125 pub const napi_bigint64_array: napi_typedarray_type = napi_typedarray_type(9);
126 pub const napi_biguint64_array: napi_typedarray_type = napi_typedarray_type(10);
127}
128#[repr(transparent)]
129#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
130pub struct napi_typedarray_type(pub ::core::ffi::c_uint);
131impl napi_status {
132 pub const napi_ok: napi_status = napi_status(0);
133 pub const napi_invalid_arg: napi_status = napi_status(1);
134 pub const napi_object_expected: napi_status = napi_status(2);
135 pub const napi_string_expected: napi_status = napi_status(3);
136 pub const napi_name_expected: napi_status = napi_status(4);
137 pub const napi_function_expected: napi_status = napi_status(5);
138 pub const napi_number_expected: napi_status = napi_status(6);
139 pub const napi_boolean_expected: napi_status = napi_status(7);
140 pub const napi_array_expected: napi_status = napi_status(8);
141 pub const napi_generic_failure: napi_status = napi_status(9);
142 pub const napi_pending_exception: napi_status = napi_status(10);
143 pub const napi_cancelled: napi_status = napi_status(11);
144 pub const napi_escape_called_twice: napi_status = napi_status(12);
145 pub const napi_handle_scope_mismatch: napi_status = napi_status(13);
146 pub const napi_callback_scope_mismatch: napi_status = napi_status(14);
147 pub const napi_queue_full: napi_status = napi_status(15);
148 pub const napi_closing: napi_status = napi_status(16);
149 pub const napi_bigint_expected: napi_status = napi_status(17);
150 pub const napi_date_expected: napi_status = napi_status(18);
151 pub const napi_arraybuffer_expected: napi_status = napi_status(19);
152 pub const napi_detachable_arraybuffer_expected: napi_status = napi_status(20);
153 pub const napi_would_deadlock: napi_status = napi_status(21);
154 pub const napi_create_ark_runtime_too_many_envs: napi_status = napi_status(22);
155 pub const napi_create_ark_runtime_only_one_env_per_thread: napi_status = napi_status(23);
156 pub const napi_destroy_ark_runtime_env_not_exist: napi_status = napi_status(24);
157}
158#[repr(transparent)]
159#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
160pub struct napi_status(pub ::core::ffi::c_uint);
161pub type napi_callback = ::core::option::Option<
162 unsafe extern "C" fn(env: napi_env, info: napi_callback_info) -> napi_value,
163>;
164pub type napi_finalize = ::core::option::Option<
165 unsafe extern "C" fn(
166 env: napi_env,
167 finalize_data: *mut ::core::ffi::c_void,
168 finalize_hint: *mut ::core::ffi::c_void,
169 ),
170>;
171#[repr(C)]
172pub struct napi_property_descriptor {
173 pub utf8name: *const ::core::ffi::c_char,
174 pub name: napi_value,
175 pub method: napi_callback,
176 pub getter: napi_callback,
177 pub setter: napi_callback,
178 pub value: napi_value,
179 pub attributes: napi_property_attributes,
180 pub data: *mut ::core::ffi::c_void,
181}
182#[repr(C)]
183#[derive(Debug)]
184pub struct napi_extended_error_info {
185 pub error_message: *const ::core::ffi::c_char,
186 pub engine_reserved: *mut ::core::ffi::c_void,
187 pub engine_error_code: u32,
188 pub error_code: napi_status,
189}
190impl napi_key_collection_mode {
191 pub const napi_key_include_prototypes: napi_key_collection_mode = napi_key_collection_mode(0);
192 pub const napi_key_own_only: napi_key_collection_mode = napi_key_collection_mode(1);
193}
194#[repr(transparent)]
195#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
196pub struct napi_key_collection_mode(pub ::core::ffi::c_uint);
197impl napi_key_filter {
198 pub const napi_key_all_properties: napi_key_filter = napi_key_filter(0);
199 pub const napi_key_writable: napi_key_filter = napi_key_filter(1);
200 pub const napi_key_enumerable: napi_key_filter = napi_key_filter(2);
201 pub const napi_key_configurable: napi_key_filter = napi_key_filter(4);
202 pub const napi_key_skip_strings: napi_key_filter = napi_key_filter(8);
203 pub const napi_key_skip_symbols: napi_key_filter = napi_key_filter(16);
204}
205#[repr(transparent)]
206#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
207pub struct napi_key_filter(pub ::core::ffi::c_uint);
208impl napi_key_conversion {
209 pub const napi_key_keep_numbers: napi_key_conversion = napi_key_conversion(0);
210 pub const napi_key_numbers_to_strings: napi_key_conversion = napi_key_conversion(1);
211}
212#[repr(transparent)]
213#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
214pub struct napi_key_conversion(pub ::core::ffi::c_uint);
215#[repr(C)]
216#[derive(Debug, Copy, Clone)]
217pub struct napi_type_tag {
218 pub lower: u64,
219 pub upper: u64,
220}
221#[repr(C)]
222pub struct napi_callback_scope__ {
223 _unused: [u8; 0],
224}
225pub type napi_callback_scope = *mut napi_callback_scope__;
226#[repr(C)]
227pub struct napi_async_context__ {
228 _unused: [u8; 0],
229}
230pub type napi_async_context = *mut napi_async_context__;
231#[repr(C)]
232pub struct napi_async_work__ {
233 _unused: [u8; 0],
234}
235pub type napi_async_work = *mut napi_async_work__;
236#[repr(C)]
237pub struct napi_threadsafe_function__ {
238 _unused: [u8; 0],
239}
240pub type napi_threadsafe_function = *mut napi_threadsafe_function__;
241impl napi_threadsafe_function_release_mode {
242 pub const napi_tsfn_release: napi_threadsafe_function_release_mode =
243 napi_threadsafe_function_release_mode(0);
244 pub const napi_tsfn_abort: napi_threadsafe_function_release_mode =
245 napi_threadsafe_function_release_mode(1);
246}
247#[repr(transparent)]
248#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
249pub struct napi_threadsafe_function_release_mode(pub ::core::ffi::c_uint);
250impl napi_threadsafe_function_call_mode {
251 pub const napi_tsfn_nonblocking: napi_threadsafe_function_call_mode =
252 napi_threadsafe_function_call_mode(0);
253 pub const napi_tsfn_blocking: napi_threadsafe_function_call_mode =
254 napi_threadsafe_function_call_mode(1);
255}
256#[repr(transparent)]
257#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
258pub struct napi_threadsafe_function_call_mode(pub ::core::ffi::c_uint);
259pub type napi_async_execute_callback =
260 ::core::option::Option<unsafe extern "C" fn(env: napi_env, data: *mut ::core::ffi::c_void)>;
261pub type napi_async_complete_callback = ::core::option::Option<
262 unsafe extern "C" fn(env: napi_env, status: napi_status, data: *mut ::core::ffi::c_void),
263>;
264pub type napi_threadsafe_function_call_js = ::core::option::Option<
265 unsafe extern "C" fn(
266 env: napi_env,
267 js_callback: napi_value,
268 context: *mut ::core::ffi::c_void,
269 data: *mut ::core::ffi::c_void,
270 ),
271>;
272#[repr(C)]
273#[derive(Debug)]
274pub struct napi_node_version {
275 pub major: u32,
276 pub minor: u32,
277 pub patch: u32,
278 pub release: *const ::core::ffi::c_char,
279}
280#[repr(C)]
281pub struct napi_async_cleanup_hook_handle__ {
282 _unused: [u8; 0],
283}
284pub type napi_async_cleanup_hook_handle = *mut napi_async_cleanup_hook_handle__;
285pub type napi_async_cleanup_hook = ::core::option::Option<
286 unsafe extern "C" fn(handle: napi_async_cleanup_hook_handle, data: *mut ::core::ffi::c_void),
287>;
288#[repr(C)]
289pub struct uv_loop_s {
290 _unused: [u8; 0],
291}
292pub type napi_addon_register_func =
293 ::core::option::Option<unsafe extern "C" fn(env: napi_env, exports: napi_value) -> napi_value>;
294#[repr(C)]
295#[derive(Debug)]
296pub struct napi_module {
297 pub nm_version: ::core::ffi::c_int,
298 pub nm_flags: ::core::ffi::c_uint,
299 pub nm_filename: *const ::core::ffi::c_char,
300 pub nm_register_func: napi_addon_register_func,
301 pub nm_modname: *const ::core::ffi::c_char,
302 pub nm_priv: *mut ::core::ffi::c_void,
303 pub reserved: [*mut ::core::ffi::c_void; 4usize],
304}
305/// Native detach callback of napi_coerce_to_native_binding_object that can be used to
306/// detach the ArkTS object and the native object.
307///
308///
309/// Available since API-level: 11
310#[cfg(feature = "api-11")]
311#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
312pub type napi_native_binding_detach_callback = ::core::option::Option<
313 unsafe extern "C" fn(
314 env: napi_env,
315 native_object: *mut ::core::ffi::c_void,
316 hint: *mut ::core::ffi::c_void,
317 ) -> *mut ::core::ffi::c_void,
318>;
319/// Native attach callback of napi_coerce_to_native_binding_object that can be used to
320/// bind the ArkTS object and the native object.
321///
322///
323/// Available since API-level: 11
324#[cfg(feature = "api-11")]
325#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
326pub type napi_native_binding_attach_callback = ::core::option::Option<
327 unsafe extern "C" fn(
328 env: napi_env,
329 native_object: *mut ::core::ffi::c_void,
330 hint: *mut ::core::ffi::c_void,
331 ) -> napi_value,
332>;
333extern "C" {
334 /// Obtains the napi_extended_error_info struct, which contains the latest error information.
335 ///
336 /// # Arguments
337 ///
338 /// * `env` - Current running virtual machine context.
339 ///
340 /// * `result` - The error info about the error.
341 ///
342 ///
343 /// # Returns
344 ///
345 /// * Returns the function execution status.
346 /// [`napi_ok`] If the function executed successfully.
347 ///
348 /// [`napi_invalid_arg`] If env or result is nullptr.
349 ///
350 ///
351 /// Available since API-level: 10
352 pub fn napi_get_last_error_info(
353 env: napi_env,
354 result: *mut *const napi_extended_error_info,
355 ) -> napi_status;
356 pub fn napi_get_undefined(env: napi_env, result: *mut napi_value) -> napi_status;
357 pub fn napi_get_null(env: napi_env, result: *mut napi_value) -> napi_status;
358 pub fn napi_get_global(env: napi_env, result: *mut napi_value) -> napi_status;
359 pub fn napi_get_boolean(env: napi_env, value: bool, result: *mut napi_value) -> napi_status;
360 pub fn napi_create_object(env: napi_env, result: *mut napi_value) -> napi_status;
361 pub fn napi_create_array(env: napi_env, result: *mut napi_value) -> napi_status;
362 pub fn napi_create_array_with_length(
363 env: napi_env,
364 length: usize,
365 result: *mut napi_value,
366 ) -> napi_status;
367 pub fn napi_create_double(env: napi_env, value: f64, result: *mut napi_value) -> napi_status;
368 pub fn napi_create_int32(env: napi_env, value: i32, result: *mut napi_value) -> napi_status;
369 pub fn napi_create_uint32(env: napi_env, value: u32, result: *mut napi_value) -> napi_status;
370 pub fn napi_create_int64(env: napi_env, value: i64, result: *mut napi_value) -> napi_status;
371 pub fn napi_create_string_latin1(
372 env: napi_env,
373 str_: *const ::core::ffi::c_char,
374 length: usize,
375 result: *mut napi_value,
376 ) -> napi_status;
377 pub fn napi_create_string_utf8(
378 env: napi_env,
379 str_: *const ::core::ffi::c_char,
380 length: usize,
381 result: *mut napi_value,
382 ) -> napi_status;
383 pub fn napi_create_string_utf16(
384 env: napi_env,
385 str_: *const char16_t,
386 length: usize,
387 result: *mut napi_value,
388 ) -> napi_status;
389 pub fn napi_create_symbol(
390 env: napi_env,
391 description: napi_value,
392 result: *mut napi_value,
393 ) -> napi_status;
394 pub fn napi_create_function(
395 env: napi_env,
396 utf8name: *const ::core::ffi::c_char,
397 length: usize,
398 cb: napi_callback,
399 data: *mut ::core::ffi::c_void,
400 result: *mut napi_value,
401 ) -> napi_status;
402 /// Creates a ArkTS Error with text information.
403 /// # Arguments
404 ///
405 /// * `env` - Current running virtual machine context.
406 ///
407 /// * `code` - Optional error code to set on the error.
408 ///
409 /// * `msg` - napi_value representing the EcmaScript string to be associated with the error.
410 ///
411 /// * `result` - napi_value representing the error created.
412 ///
413 ///
414 /// # Returns
415 ///
416 /// * Returns the function execution status.
417 /// [`napi_ok`] If the function executed successfully.
418 ///
419 /// [`napi_invalid_arg`] If env, msg or result is nullptr, code is not string and number type or msg is
420 /// not a string type.
421 ///
422 ///
423 /// Available since API-level: 10
424 pub fn napi_create_error(
425 env: napi_env,
426 code: napi_value,
427 msg: napi_value,
428 result: *mut napi_value,
429 ) -> napi_status;
430 /// Creates a ArkTS TypeError with text information.
431 /// # Arguments
432 ///
433 /// * `env` - Current running virtual machine context.
434 ///
435 /// * `code` - Optional error code to set on the error.
436 ///
437 /// * `msg` - napi_value representing the EcmaScript string to be associated with the error.
438 ///
439 /// * `result` - napi_value representing the error created.
440 ///
441 ///
442 /// # Returns
443 ///
444 /// * Returns the function execution status.
445 /// [`napi_ok`] If the function executed successfully.
446 ///
447 /// [`napi_invalid_arg`] If env, msg or result is nullptr, code is not string and number type or msg is
448 /// not a string type.
449 ///
450 ///
451 /// Available since API-level: 10
452 pub fn napi_create_type_error(
453 env: napi_env,
454 code: napi_value,
455 msg: napi_value,
456 result: *mut napi_value,
457 ) -> napi_status;
458 /// Creates a ArkTS RangeError with text information.
459 /// # Arguments
460 ///
461 /// * `env` - Current running virtual machine context.
462 ///
463 /// * `code` - Optional error code to set on the error.
464 ///
465 /// * `msg` - napi_value representing the EcmaScript string to be associated with the error.
466 ///
467 /// * `result` - napi_value representing the error created.
468 ///
469 ///
470 /// # Returns
471 ///
472 /// * Returns the function execution status.
473 /// [`napi_ok`] If the function executed successfully.
474 ///
475 /// [`napi_invalid_arg`] If env, msg or result is nullptr, code is not string and number type or msg is
476 /// not a string type.
477 ///
478 ///
479 /// Available since API-level: 10
480 pub fn napi_create_range_error(
481 env: napi_env,
482 code: napi_value,
483 msg: napi_value,
484 result: *mut napi_value,
485 ) -> napi_status;
486 pub fn napi_typeof(
487 env: napi_env,
488 value: napi_value,
489 result: *mut napi_valuetype,
490 ) -> napi_status;
491 pub fn napi_get_value_double(env: napi_env, value: napi_value, result: *mut f64)
492 -> napi_status;
493 pub fn napi_get_value_int32(env: napi_env, value: napi_value, result: *mut i32) -> napi_status;
494 pub fn napi_get_value_uint32(env: napi_env, value: napi_value, result: *mut u32)
495 -> napi_status;
496 pub fn napi_get_value_int64(env: napi_env, value: napi_value, result: *mut i64) -> napi_status;
497 pub fn napi_get_value_bool(env: napi_env, value: napi_value, result: *mut bool) -> napi_status;
498 pub fn napi_get_value_string_latin1(
499 env: napi_env,
500 value: napi_value,
501 buf: *mut ::core::ffi::c_char,
502 bufsize: usize,
503 result: *mut usize,
504 ) -> napi_status;
505 pub fn napi_get_value_string_utf8(
506 env: napi_env,
507 value: napi_value,
508 buf: *mut ::core::ffi::c_char,
509 bufsize: usize,
510 result: *mut usize,
511 ) -> napi_status;
512 pub fn napi_get_value_string_utf16(
513 env: napi_env,
514 value: napi_value,
515 buf: *mut char16_t,
516 bufsize: usize,
517 result: *mut usize,
518 ) -> napi_status;
519 pub fn napi_coerce_to_bool(
520 env: napi_env,
521 value: napi_value,
522 result: *mut napi_value,
523 ) -> napi_status;
524 pub fn napi_coerce_to_number(
525 env: napi_env,
526 value: napi_value,
527 result: *mut napi_value,
528 ) -> napi_status;
529 pub fn napi_coerce_to_object(
530 env: napi_env,
531 value: napi_value,
532 result: *mut napi_value,
533 ) -> napi_status;
534 pub fn napi_coerce_to_string(
535 env: napi_env,
536 value: napi_value,
537 result: *mut napi_value,
538 ) -> napi_status;
539 pub fn napi_get_prototype(
540 env: napi_env,
541 object: napi_value,
542 result: *mut napi_value,
543 ) -> napi_status;
544 pub fn napi_get_property_names(
545 env: napi_env,
546 object: napi_value,
547 result: *mut napi_value,
548 ) -> napi_status;
549 pub fn napi_set_property(
550 env: napi_env,
551 object: napi_value,
552 key: napi_value,
553 value: napi_value,
554 ) -> napi_status;
555 pub fn napi_has_property(
556 env: napi_env,
557 object: napi_value,
558 key: napi_value,
559 result: *mut bool,
560 ) -> napi_status;
561 pub fn napi_get_property(
562 env: napi_env,
563 object: napi_value,
564 key: napi_value,
565 result: *mut napi_value,
566 ) -> napi_status;
567 pub fn napi_delete_property(
568 env: napi_env,
569 object: napi_value,
570 key: napi_value,
571 result: *mut bool,
572 ) -> napi_status;
573 /// Check if the given ArkTS Object has the named own property or not.
574 /// # Arguments
575 ///
576 /// * `env` - Current running virtual machine context.
577 ///
578 /// * `object` - The ArkTS object.
579 ///
580 /// * `key` - The name of the property to check.
581 ///
582 /// * `result` - Whether the own property exists on the object or not.
583 ///
584 ///
585 /// # Returns
586 ///
587 /// * Returns the function execution status.
588 /// [`napi_ok`] If the function executed successfully.
589 ///
590 /// [`napi_invalid_arg`] If the param env, object, key and(or) result is nullptr.
591 ///
592 /// [`napi_object_expected`] If the param object is not an ArkTS Object.
593 ///
594 /// [`napi_pending_exception`] If have uncaught exception, or exception occurs in execution.
595 ///
596 ///
597 /// Available since API-level: 10
598 pub fn napi_has_own_property(
599 env: napi_env,
600 object: napi_value,
601 key: napi_value,
602 result: *mut bool,
603 ) -> napi_status;
604 pub fn napi_set_named_property(
605 env: napi_env,
606 object: napi_value,
607 utf8name: *const ::core::ffi::c_char,
608 value: napi_value,
609 ) -> napi_status;
610 pub fn napi_has_named_property(
611 env: napi_env,
612 object: napi_value,
613 utf8name: *const ::core::ffi::c_char,
614 result: *mut bool,
615 ) -> napi_status;
616 pub fn napi_get_named_property(
617 env: napi_env,
618 object: napi_value,
619 utf8name: *const ::core::ffi::c_char,
620 result: *mut napi_value,
621 ) -> napi_status;
622 pub fn napi_set_element(
623 env: napi_env,
624 object: napi_value,
625 index: u32,
626 value: napi_value,
627 ) -> napi_status;
628 pub fn napi_has_element(
629 env: napi_env,
630 object: napi_value,
631 index: u32,
632 result: *mut bool,
633 ) -> napi_status;
634 pub fn napi_get_element(
635 env: napi_env,
636 object: napi_value,
637 index: u32,
638 result: *mut napi_value,
639 ) -> napi_status;
640 pub fn napi_delete_element(
641 env: napi_env,
642 object: napi_value,
643 index: u32,
644 result: *mut bool,
645 ) -> napi_status;
646 pub fn napi_define_properties(
647 env: napi_env,
648 object: napi_value,
649 property_count: usize,
650 properties: *const napi_property_descriptor,
651 ) -> napi_status;
652 pub fn napi_is_array(env: napi_env, value: napi_value, result: *mut bool) -> napi_status;
653 pub fn napi_get_array_length(env: napi_env, value: napi_value, result: *mut u32)
654 -> napi_status;
655 pub fn napi_strict_equals(
656 env: napi_env,
657 lhs: napi_value,
658 rhs: napi_value,
659 result: *mut bool,
660 ) -> napi_status;
661 pub fn napi_call_function(
662 env: napi_env,
663 recv: napi_value,
664 func: napi_value,
665 argc: usize,
666 argv: *const napi_value,
667 result: *mut napi_value,
668 ) -> napi_status;
669 pub fn napi_new_instance(
670 env: napi_env,
671 constructor: napi_value,
672 argc: usize,
673 argv: *const napi_value,
674 result: *mut napi_value,
675 ) -> napi_status;
676 pub fn napi_instanceof(
677 env: napi_env,
678 object: napi_value,
679 constructor: napi_value,
680 result: *mut bool,
681 ) -> napi_status;
682 pub fn napi_get_cb_info(
683 env: napi_env,
684 cbinfo: napi_callback_info,
685 argc: *mut usize,
686 argv: *mut napi_value,
687 this_arg: *mut napi_value,
688 data: *mut *mut ::core::ffi::c_void,
689 ) -> napi_status;
690 pub fn napi_get_new_target(
691 env: napi_env,
692 cbinfo: napi_callback_info,
693 result: *mut napi_value,
694 ) -> napi_status;
695 /// Defines an ArkTS class, including constructor function and properties.
696 /// # Arguments
697 ///
698 /// * `env` - Current running virtual machine context.
699 ///
700 /// * `utf8name` - Name of the ArkTS constructor function.
701 ///
702 /// * `length` - The length of the utf8name in bytes, or NAPI_AUTO_LENGTH if it is null-terminated.
703 ///
704 /// * `constructor` - Callback function that handles constructing instances of the class.
705 ///
706 /// * `data` - Optional data to be passed to the constructor callback as the data property of the callback info.
707 ///
708 /// * `property_count` - Number of items in the properties array argument.
709 ///
710 /// * `properties` - Array of property descriptors.
711 ///
712 /// * `result` - A napi_value representing the constructor function for the class.
713 ///
714 ///
715 /// # Returns
716 ///
717 /// * Returns the function execution status.
718 /// [`napi_ok`] If the function executed successfully.
719 /// execution.
720 ///
721 /// [`napi_invalid_arg`] If the param env, utf8name and(or) result is nullptr. If napi_property_descriptor
722 /// is nullptr but property_count greater than 0.
723 ///
724 /// [`napi_function_expected`] If the param func is not an ArkTS Function.
725 ///
726 /// [`napi_pending_exception`] If have uncaught exception, or exception occurs in execution.
727 ///
728 ///
729 /// Available since API-level: 10
730 pub fn napi_define_class(
731 env: napi_env,
732 utf8name: *const ::core::ffi::c_char,
733 length: usize,
734 constructor: napi_callback,
735 data: *mut ::core::ffi::c_void,
736 property_count: usize,
737 properties: *const napi_property_descriptor,
738 result: *mut napi_value,
739 ) -> napi_status;
740 pub fn napi_wrap(
741 env: napi_env,
742 js_object: napi_value,
743 native_object: *mut ::core::ffi::c_void,
744 finalize_cb: napi_finalize,
745 finalize_hint: *mut ::core::ffi::c_void,
746 result: *mut napi_ref,
747 ) -> napi_status;
748 pub fn napi_unwrap(
749 env: napi_env,
750 js_object: napi_value,
751 result: *mut *mut ::core::ffi::c_void,
752 ) -> napi_status;
753 pub fn napi_remove_wrap(
754 env: napi_env,
755 js_object: napi_value,
756 result: *mut *mut ::core::ffi::c_void,
757 ) -> napi_status;
758 pub fn napi_create_external(
759 env: napi_env,
760 data: *mut ::core::ffi::c_void,
761 finalize_cb: napi_finalize,
762 finalize_hint: *mut ::core::ffi::c_void,
763 result: *mut napi_value,
764 ) -> napi_status;
765 pub fn napi_get_value_external(
766 env: napi_env,
767 value: napi_value,
768 result: *mut *mut ::core::ffi::c_void,
769 ) -> napi_status;
770 /// Creates a reference for an object to extend its lifespan. The caller needs to manage the reference lifespan.
771 /// # Arguments
772 ///
773 /// * `env` - Current running virtual machine context.
774 ///
775 /// * `value` - The napi_value that is being referenced.
776 ///
777 /// * `initial_refcount` - The initial count for the new reference.
778 ///
779 /// * `result` - napi_ref pointing to the new reference.
780 ///
781 ///
782 /// # Returns
783 ///
784 /// * Returns the function execution status.
785 /// [`napi_ok`] If the function executed successfully.
786 ///
787 /// [`napi_invalid_arg`] If env, value or result is nullptr.
788 ///
789 ///
790 /// Available since API-level: 10
791 pub fn napi_create_reference(
792 env: napi_env,
793 value: napi_value,
794 initial_refcount: u32,
795 result: *mut napi_ref,
796 ) -> napi_status;
797 /// Deletes the reference passed in.
798 /// # Arguments
799 ///
800 /// * `env` - Current running virtual machine context.
801 ///
802 /// * `ref` - The napi_ref to be deleted.
803 ///
804 ///
805 /// # Returns
806 ///
807 /// * Returns the function execution status.
808 /// [`napi_ok`] If the function executed successfully.
809 ///
810 /// [`napi_invalid_arg`] If env or ref is nullptr.
811 ///
812 ///
813 /// Available since API-level: 10
814 pub fn napi_delete_reference(env: napi_env, ref_: napi_ref) -> napi_status;
815 /// Increments the reference count for the reference passed in and returns the count.
816 /// # Arguments
817 ///
818 /// * `env` - Current running virtual machine context.
819 ///
820 /// * `ref` - The napi_ref whose reference count will be incremented.
821 ///
822 /// * `result` - The new reference count.
823 ///
824 ///
825 /// # Returns
826 ///
827 /// * Returns the function execution status.
828 /// [`napi_ok`] If the function executed successfully.
829 ///
830 /// [`napi_invalid_arg`] If env or ref is nullptr.
831 ///
832 ///
833 /// Available since API-level: 10
834 pub fn napi_reference_ref(env: napi_env, ref_: napi_ref, result: *mut u32) -> napi_status;
835 /// Decrements the reference count for the reference passed in and returns the count.
836 /// # Arguments
837 ///
838 /// * `env` - Current running virtual machine context.
839 ///
840 /// * `ref` - The napi_ref whose reference count will be decremented.
841 ///
842 /// * `result` - The new reference count.
843 ///
844 ///
845 /// # Returns
846 ///
847 /// * Returns the function execution status.
848 /// [`napi_ok`] If the function executed successfully.
849 ///
850 /// [`napi_invalid_arg`] If env or ref is nullptr.
851 ///
852 ///
853 /// Available since API-level: 10
854 pub fn napi_reference_unref(env: napi_env, ref_: napi_ref, result: *mut u32) -> napi_status;
855 /// Obtains the ArkTS Object associated with the reference.
856 /// # Arguments
857 ///
858 /// * `env` - Current running virtual machine context.
859 ///
860 /// * `ref` - The napi_ref of the value being requested.
861 ///
862 /// * `result` - The napi_value referenced by the napi_ref.
863 ///
864 ///
865 /// # Returns
866 ///
867 /// * Returns the function execution status.
868 /// [`napi_ok`] If the function executed successfully.
869 ///
870 /// [`napi_invalid_arg`] If env, ref or result is nullptr.
871 ///
872 ///
873 /// Available since API-level: 10
874 pub fn napi_get_reference_value(
875 env: napi_env,
876 ref_: napi_ref,
877 result: *mut napi_value,
878 ) -> napi_status;
879 /// Opens a scope.
880 /// # Arguments
881 ///
882 /// * `env` - Current running virtual machine context.
883 ///
884 /// * `result` - napi_value representing the new scope.
885 ///
886 ///
887 /// # Returns
888 ///
889 /// * Returns the function execution status.
890 /// [`napi_ok`] If the function executed successfully.
891 ///
892 /// [`napi_invalid_arg`] If env or result is nullptr.
893 ///
894 ///
895 /// Available since API-level: 10
896 pub fn napi_open_handle_scope(env: napi_env, result: *mut napi_handle_scope) -> napi_status;
897 /// Closes the scope passed in. After the scope is closed, all references declared in it are closed.
898 /// # Arguments
899 ///
900 /// * `env` - Current running virtual machine context.
901 ///
902 /// * `scope` - The scope to close.
903 ///
904 ///
905 /// # Returns
906 ///
907 /// * Returns the function execution status.
908 /// [`napi_ok`] If the function executed successfully.
909 ///
910 /// [`napi_invalid_arg`] If env or scope is nullptr.
911 ///
912 /// [`napi_handle_scope_mismatch`] If there is no scope still existed.
913 ///
914 ///
915 /// Available since API-level: 10
916 pub fn napi_close_handle_scope(env: napi_env, scope: napi_handle_scope) -> napi_status;
917 /// Opens an escapable handle scope from which the declared values can be returned to the outer scope.
918 /// # Arguments
919 ///
920 /// * `env` - Current running virtual machine context.
921 ///
922 /// * `result` - The new scope.
923 ///
924 ///
925 /// # Returns
926 ///
927 /// * Returns the function execution status.
928 /// [`napi_ok`] If the function executed successfully.
929 ///
930 /// [`napi_invalid_arg`] If env or result is nullptr.
931 ///
932 ///
933 /// Available since API-level: 10
934 pub fn napi_open_escapable_handle_scope(
935 env: napi_env,
936 result: *mut napi_escapable_handle_scope,
937 ) -> napi_status;
938 /// Closes the escapable handle scope passed in.
939 /// # Arguments
940 ///
941 /// * `env` - Current running virtual machine context.
942 ///
943 /// * `scope` - The scope to close.
944 ///
945 ///
946 /// # Returns
947 ///
948 /// * Returns the function execution status.
949 /// [`napi_ok`] If the function executed successfully.
950 ///
951 /// [`napi_invalid_arg`] If env or scope is nullptr.
952 ///
953 /// [`napi_handle_scope_mismatch`] If there is no scope still existed.
954 ///
955 ///
956 /// Available since API-level: 10
957 pub fn napi_close_escapable_handle_scope(
958 env: napi_env,
959 scope: napi_escapable_handle_scope,
960 ) -> napi_status;
961 /// Promotes the handle to the input ArkTS object so that it is valid for the lifespan of its outer scope.
962 /// # Arguments
963 ///
964 /// * `env` - Current running virtual machine context.
965 ///
966 /// * `scope` - Current scope.
967 ///
968 /// * `escapee` - The ArkTS object to be escaped.
969 ///
970 /// * `result` - The handle to the escaped object in the outer scope.
971 ///
972 ///
973 /// # Returns
974 ///
975 /// * Returns the function execution status.
976 /// [`napi_ok`] If the function executed successfully.
977 ///
978 /// [`napi_invalid_arg`] If env, scope, escapee or result is nullptr.
979 ///
980 ///
981 /// Available since API-level: 10
982 pub fn napi_escape_handle(
983 env: napi_env,
984 scope: napi_escapable_handle_scope,
985 escapee: napi_value,
986 result: *mut napi_value,
987 ) -> napi_status;
988 /// Throws a ArkTS error.
989 /// # Arguments
990 ///
991 /// * `env` - Current running virtual machine context.
992 ///
993 /// * `error` - The ArkTS error to be thrown.
994 ///
995 ///
996 /// # Returns
997 ///
998 /// * Returns the function execution status.
999 /// [`napi_ok`] If the function executed successfully.
1000 ///
1001 /// [`napi_invalid_arg`] If env or error is nullptr, or error is not an error object.
1002 ///
1003 ///
1004 /// Available since API-level: 10
1005 pub fn napi_throw(env: napi_env, error: napi_value) -> napi_status;
1006 /// Throws a ArkTS Error with text information.
1007 /// # Arguments
1008 ///
1009 /// * `env` - Current running virtual machine context.
1010 ///
1011 /// * `code` - Optional error code to set on the error.
1012 ///
1013 /// * `msg` - C string representing the text to be associated with the error.
1014 ///
1015 ///
1016 /// # Returns
1017 ///
1018 /// * Returns the function execution status.
1019 /// [`napi_ok`] If the function executed successfully.
1020 ///
1021 /// [`napi_invalid_arg`] If env or msg is nullptr.
1022 ///
1023 ///
1024 /// Available since API-level: 10
1025 pub fn napi_throw_error(
1026 env: napi_env,
1027 code: *const ::core::ffi::c_char,
1028 msg: *const ::core::ffi::c_char,
1029 ) -> napi_status;
1030 /// Throws a ArkTS TypeError with text information.
1031 /// # Arguments
1032 ///
1033 /// * `env` - Current running virtual machine context.
1034 ///
1035 /// * `code` - Optional error code to set on the error.
1036 ///
1037 /// * `msg` - C string representing the text to be associated with the error.
1038 ///
1039 ///
1040 /// # Returns
1041 ///
1042 /// * Returns the function execution status.
1043 /// [`napi_ok`] If the function executed successfully.
1044 ///
1045 /// [`napi_invalid_arg`] If env or msg is nullptr.
1046 ///
1047 ///
1048 /// Available since API-level: 10
1049 pub fn napi_throw_type_error(
1050 env: napi_env,
1051 code: *const ::core::ffi::c_char,
1052 msg: *const ::core::ffi::c_char,
1053 ) -> napi_status;
1054 /// Throws a ArkTS RangeError with text information.
1055 /// # Arguments
1056 ///
1057 /// * `env` - Current running virtual machine context.
1058 ///
1059 /// * `code` - Optional error code to set on the error.
1060 ///
1061 /// * `msg` - C string representing the text to be associated with the error.
1062 ///
1063 ///
1064 /// # Returns
1065 ///
1066 /// * Returns the function execution status.
1067 /// [`napi_ok`] If the function executed successfully.
1068 ///
1069 /// [`napi_invalid_arg`] If env or msg is nullptr.
1070 ///
1071 ///
1072 /// Available since API-level: 10
1073 pub fn napi_throw_range_error(
1074 env: napi_env,
1075 code: *const ::core::ffi::c_char,
1076 msg: *const ::core::ffi::c_char,
1077 ) -> napi_status;
1078 /// Checks whether a 'napi_value' is an error object.
1079 /// # Arguments
1080 ///
1081 /// * `env` - Current running virtual machine context.
1082 ///
1083 /// * `value` - The value to check
1084 ///
1085 /// * `result` - Boolean value that is set to true if the value represents an error object, false otherwise.
1086 ///
1087 ///
1088 /// # Returns
1089 ///
1090 /// * Returns the function execution status.
1091 /// [`napi_ok`] If the function executed successfully.
1092 ///
1093 /// [`napi_invalid_arg`] If env, value or result is nullptr.
1094 ///
1095 ///
1096 /// Available since API-level: 10
1097 pub fn napi_is_error(env: napi_env, value: napi_value, result: *mut bool) -> napi_status;
1098 /// Checks whether an exception occurs.
1099 /// # Arguments
1100 ///
1101 /// * `env` - Current running virtual machine context.
1102 ///
1103 /// * `result` - Boolean value that is true if there is a pending exception.
1104 ///
1105 ///
1106 /// # Returns
1107 ///
1108 /// * Returns the function execution status.
1109 /// [`napi_ok`] If the function executed successfully.
1110 ///
1111 /// [`napi_invalid_arg`] If env or result is nullptr.
1112 ///
1113 ///
1114 /// Available since API-level: 10
1115 pub fn napi_is_exception_pending(env: napi_env, result: *mut bool) -> napi_status;
1116 /// Obtains and clears the latest exception.
1117 /// # Arguments
1118 ///
1119 /// * `env` - Current running virtual machine context.
1120 ///
1121 /// * `result` - The exception if there is a pending exception; otherwise return a null value.
1122 ///
1123 ///
1124 /// # Returns
1125 ///
1126 /// * Returns the function execution status.
1127 /// [`napi_ok`] If the function executed successfully.
1128 ///
1129 /// [`napi_invalid_arg`] If env or result is nullptr.
1130 ///
1131 ///
1132 /// Available since API-level: 10
1133 pub fn napi_get_and_clear_last_exception(env: napi_env, result: *mut napi_value)
1134 -> napi_status;
1135 pub fn napi_is_arraybuffer(env: napi_env, value: napi_value, result: *mut bool) -> napi_status;
1136 pub fn napi_create_arraybuffer(
1137 env: napi_env,
1138 byte_length: usize,
1139 data: *mut *mut ::core::ffi::c_void,
1140 result: *mut napi_value,
1141 ) -> napi_status;
1142 pub fn napi_create_external_arraybuffer(
1143 env: napi_env,
1144 external_data: *mut ::core::ffi::c_void,
1145 byte_length: usize,
1146 finalize_cb: napi_finalize,
1147 finalize_hint: *mut ::core::ffi::c_void,
1148 result: *mut napi_value,
1149 ) -> napi_status;
1150 pub fn napi_get_arraybuffer_info(
1151 env: napi_env,
1152 arraybuffer: napi_value,
1153 data: *mut *mut ::core::ffi::c_void,
1154 byte_length: *mut usize,
1155 ) -> napi_status;
1156 pub fn napi_is_typedarray(env: napi_env, value: napi_value, result: *mut bool) -> napi_status;
1157 pub fn napi_create_typedarray(
1158 env: napi_env,
1159 type_: napi_typedarray_type,
1160 length: usize,
1161 arraybuffer: napi_value,
1162 byte_offset: usize,
1163 result: *mut napi_value,
1164 ) -> napi_status;
1165 pub fn napi_get_typedarray_info(
1166 env: napi_env,
1167 typedarray: napi_value,
1168 type_: *mut napi_typedarray_type,
1169 length: *mut usize,
1170 data: *mut *mut ::core::ffi::c_void,
1171 arraybuffer: *mut napi_value,
1172 byte_offset: *mut usize,
1173 ) -> napi_status;
1174 pub fn napi_create_dataview(
1175 env: napi_env,
1176 length: usize,
1177 arraybuffer: napi_value,
1178 byte_offset: usize,
1179 result: *mut napi_value,
1180 ) -> napi_status;
1181 pub fn napi_is_dataview(env: napi_env, value: napi_value, result: *mut bool) -> napi_status;
1182 pub fn napi_get_dataview_info(
1183 env: napi_env,
1184 dataview: napi_value,
1185 bytelength: *mut usize,
1186 data: *mut *mut ::core::ffi::c_void,
1187 arraybuffer: *mut napi_value,
1188 byte_offset: *mut usize,
1189 ) -> napi_status;
1190 pub fn napi_get_version(env: napi_env, result: *mut u32) -> napi_status;
1191 /// Creates a deferred object and an ArkTS promise.
1192 /// # Arguments
1193 ///
1194 /// * `env` - Current running virtual machine context.
1195 ///
1196 /// * `deferred` - The created deferred object which will be passed to 'napi_resolve_deferred()' or
1197 /// 'napi_reject_deferred()' to resolve or reject the promise.
1198 ///
1199 /// * `promise` - The ArkTS promise which is associated with the deferred object.
1200 ///
1201 /// # Returns
1202 ///
1203 /// * Returns the function execution status.
1204 /// [`napi_ok`] If the function executed successfully.
1205 ///
1206 /// [`napi_invalid_arg`] If env, deferred or resolution is nullptr.
1207 ///
1208 /// [`napi_pending_exception`] If a ArkTS exception existed when the function was called.
1209 ///
1210 /// [`napi_generic_failure`] If create promise failed.
1211 ///
1212 ///
1213 /// Available since API-level: 10
1214 pub fn napi_create_promise(
1215 env: napi_env,
1216 deferred: *mut napi_deferred,
1217 promise: *mut napi_value,
1218 ) -> napi_status;
1219 /// Resolves a promise by way of the deferred object associated.
1220 /// # Arguments
1221 ///
1222 /// * `env` - Current running virtual machine context.
1223 ///
1224 /// * `deferred` - The deferred object which is utilized to resolve the promise.
1225 ///
1226 /// * `resolution` - The resolution value used to resolve the promise.
1227 ///
1228 /// # Returns
1229 ///
1230 /// * Returns the function execution status.
1231 /// [`napi_ok`] If the function executed successfully.
1232 ///
1233 /// [`napi_invalid_arg`] If env, deferred or resolution is nullptr.
1234 ///
1235 /// [`napi_pending_exception`] If a ArkTS exception existed when the function was called.
1236 ///
1237 ///
1238 /// Available since API-level: 10
1239 pub fn napi_resolve_deferred(
1240 env: napi_env,
1241 deferred: napi_deferred,
1242 resolution: napi_value,
1243 ) -> napi_status;
1244 /// Rejects a promise by way of the deferred object associated.
1245 /// # Arguments
1246 ///
1247 /// * `env` - Current running virtual machine context.
1248 ///
1249 /// * `deferred` - The deferred object which is utilized to reject the promise.
1250 ///
1251 /// * `rejection` - The rejection value used to reject the promise.
1252 ///
1253 /// # Returns
1254 ///
1255 /// * Returns the function execution status.
1256 /// [`napi_ok`] If the function executed successfully.
1257 ///
1258 /// [`napi_invalid_arg`] If env, deferred or rejection is nullptr.
1259 ///
1260 /// [`napi_pending_exception`] If a ArkTS exception existed when the function was called.
1261 ///
1262 ///
1263 /// Available since API-level: 10
1264 pub fn napi_reject_deferred(
1265 env: napi_env,
1266 deferred: napi_deferred,
1267 rejection: napi_value,
1268 ) -> napi_status;
1269 /// Checks whether the given 'napi_value' is a promise object.
1270 /// # Arguments
1271 ///
1272 /// * `env` - Current running virtual machine context.
1273 ///
1274 /// * `value` - The 'napi_value' to be checked.
1275 ///
1276 /// * `is_promise` - Boolean value that is set to true if the 'value' is a promise object, false otherwise.
1277 ///
1278 /// # Returns
1279 ///
1280 /// * Returns the function execution status.
1281 /// [`napi_ok`] If the function executed successfully.
1282 ///
1283 /// [`napi_invalid_arg`] If env, value or is_promise is nullptr.
1284 ///
1285 ///
1286 /// Available since API-level: 10
1287 pub fn napi_is_promise(env: napi_env, value: napi_value, is_promise: *mut bool) -> napi_status;
1288 pub fn napi_run_script(
1289 env: napi_env,
1290 script: napi_value,
1291 result: *mut napi_value,
1292 ) -> napi_status;
1293 pub fn napi_adjust_external_memory(
1294 env: napi_env,
1295 change_in_bytes: i64,
1296 adjusted_value: *mut i64,
1297 ) -> napi_status;
1298 /// Creates an ArkTS 'Date' object from C double data
1299 /// # Arguments
1300 ///
1301 /// * `env` - Current running virtual machine context.
1302 ///
1303 /// * `time` - ArkTS time value in milliseconds format since 01 January, 1970 UTC.
1304 ///
1305 /// * `result` - Created ArkTS data object.
1306 ///
1307 /// # Returns
1308 ///
1309 /// * Returns the function execution status.
1310 /// [`napi_ok`] If the function executed successfully.
1311 ///
1312 /// [`napi_invalid_arg`] If env or result is nullptr.
1313 ///
1314 /// [`napi_pending_exception`] If a ArkTS exception existed when the function was called.
1315 ///
1316 ///
1317 /// Available since API-level: 10
1318 pub fn napi_create_date(env: napi_env, time: f64, result: *mut napi_value) -> napi_status;
1319 /// Checks whether the given ArkTS value is a 'Date' object. You can use this API to check the type
1320 /// of the parameter passed from ArkTS.
1321 /// # Arguments
1322 ///
1323 /// * `env` - Current running virtual machine context.
1324 ///
1325 /// * `value` - ArkTS data object.
1326 ///
1327 /// * `is_date` - Boolean value that is set to true if the 'value' is a 'Date' object, false otherwise.
1328 ///
1329 /// # Returns
1330 ///
1331 /// * Returns the function execution status.
1332 /// [`napi_ok`] If the function executed successfully.
1333 ///
1334 /// [`napi_invalid_arg`] If env, value or is_date is nullptr.
1335 ///
1336 ///
1337 /// Available since API-level: 10
1338 pub fn napi_is_date(env: napi_env, value: napi_value, is_date: *mut bool) -> napi_status;
1339 /// Obtains the C equivalent of the given ArkTS 'Date' object.
1340 ///
1341 /// # Arguments
1342 ///
1343 /// * `env` - Current running virtual machine context.
1344 ///
1345 /// * `value` - ArkTS data object.
1346 ///
1347 /// * `result` - C time value in milliseconds format since 01 January, 1970 UTC.
1348 ///
1349 /// # Returns
1350 ///
1351 /// * Returns the function execution status.
1352 /// [`napi_ok`] If the function executed successfully.
1353 ///
1354 /// [`napi_invalid_arg`] If env, value or result is nullptr.
1355 ///
1356 /// [`napi_pending_exception`] If a ArkTS exception existed when the function was called.
1357 ///
1358 /// [`napi_date_expected`] If the 'value' is not a 'Date' object.
1359 ///
1360 ///
1361 /// Available since API-level: 10
1362 pub fn napi_get_date_value(env: napi_env, value: napi_value, result: *mut f64) -> napi_status;
1363 /// Adds a 'napi_finalize' callback, which will be called when the ArkTS object is garbage-collected.
1364 ///
1365 /// # Arguments
1366 ///
1367 /// * `env` - Current running virtual machine context.
1368 ///
1369 /// * `js_object` - The ArkTS object value.
1370 ///
1371 /// * `native_object` - Native object to bind with the ArkTS object.
1372 ///
1373 /// * `finalize_cb` - Native callback that can be used to free the native object when the ArkTS object is
1374 /// garbage-collected.
1375 ///
1376 /// * `finalize_hint` - Optional contextual hint that is passed to the finalize callback.
1377 ///
1378 /// * `result` - Optional reference of the ArkTS object.
1379 ///
1380 ///
1381 /// # Returns
1382 ///
1383 /// * Return the function execution status.
1384 ///
1385 /// Available since API-level: 11
1386 #[cfg(feature = "api-11")]
1387 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
1388 pub fn napi_add_finalizer(
1389 env: napi_env,
1390 js_object: napi_value,
1391 native_object: *mut ::core::ffi::c_void,
1392 finalize_cb: napi_finalize,
1393 finalize_hint: *mut ::core::ffi::c_void,
1394 result: *mut napi_ref,
1395 ) -> napi_status;
1396 /// Creates a ArkTS BigInt from C int64 data.
1397 ///
1398 /// # Arguments
1399 ///
1400 /// * `env` - Current running virtual machine context.
1401 ///
1402 /// * `value` - C int64 data.
1403 ///
1404 /// * `result` - Created ArkTS BigInt object from C int64 data.
1405 ///
1406 /// # Returns
1407 ///
1408 /// * Returns the function execution status.
1409 /// [`napi_ok`] If the function executed successfully.
1410 ///
1411 /// [`napi_invalid_arg`] If env or result is nullptr.
1412 ///
1413 ///
1414 /// Available since API-level: 10
1415 pub fn napi_create_bigint_int64(
1416 env: napi_env,
1417 value: i64,
1418 result: *mut napi_value,
1419 ) -> napi_status;
1420 /// Creates a ArkTS BigInt from C int64 data.
1421 ///
1422 /// # Arguments
1423 ///
1424 /// * `env` - Current running virtual machine context.
1425 ///
1426 /// * `value` - C int64 data.
1427 ///
1428 /// * `result` - Created ArkTS BigInt object from C int64 data.
1429 ///
1430 /// # Returns
1431 ///
1432 /// * Returns the function execution status.
1433 /// [`napi_ok`] If the function executed successfully.
1434 ///
1435 /// [`napi_invalid_arg`] If env or result is nullptr.
1436 ///
1437 ///
1438 /// Available since API-level: 10
1439 pub fn napi_create_bigint_uint64(
1440 env: napi_env,
1441 value: u64,
1442 result: *mut napi_value,
1443 ) -> napi_status;
1444 /// Creates a single ArkTS BigInt from a C uint64 array.
1445 ///
1446 /// # Arguments
1447 ///
1448 /// * `env` - Current running virtual machine context.
1449 ///
1450 /// * `sign_bit` - Sign bit of the BigInt. If sign_bit is 0, the BigInt is positive, otherwise it is negative.
1451 ///
1452 /// * `word_count` - The size of the words array.
1453 ///
1454 /// * `words` - C uint64 array in little-endian 64-bit format.
1455 ///
1456 /// * `result` - Created ArkTS BigInt object from C int64 array.
1457 ///
1458 /// # Returns
1459 ///
1460 /// * Returns the function execution status.
1461 /// [`napi_ok`] If the function executed successfully.
1462 ///
1463 /// [`napi_invalid_arg`] If env, words or result is nullptr or word_count is larger than 2147483647.
1464 ///
1465 /// [`napi_pending_exception`] If a ArkTS exception existed when the function was called.
1466 ///
1467 ///
1468 /// Available since API-level: 10
1469 pub fn napi_create_bigint_words(
1470 env: napi_env,
1471 sign_bit: ::core::ffi::c_int,
1472 word_count: usize,
1473 words: *const u64,
1474 result: *mut napi_value,
1475 ) -> napi_status;
1476 /// Obtains a signed 64-bit integer from an ArkTS BigInt object.
1477 ///
1478 /// # Arguments
1479 ///
1480 /// * `env` - Current running virtual machine context.
1481 ///
1482 /// * `value` - ArkTS BigInt object.
1483 ///
1484 /// * `result` - Pointer points to the location where store the C signed 64-bit integer value.
1485 ///
1486 /// * `lossless` - Indicates whether the conversion is lossless. If lossless is true, the conversion is lossless,
1487 /// false otherwise.
1488 ///
1489 /// # Returns
1490 ///
1491 /// * Returns the function execution status.
1492 /// [`napi_ok`] If the function executed successfully.
1493 ///
1494 /// [`napi_invalid_arg`] If env, value, result or lossless is nullptr or word_count is larger than
1495 ///
1496 /// 2147483647.
1497 ///
1498 /// [`napi_bigint_expected`] If the 'value' is not an ArkTS bigint object.
1499 ///
1500 ///
1501 /// Available since API-level: 10
1502 pub fn napi_get_value_bigint_int64(
1503 env: napi_env,
1504 value: napi_value,
1505 result: *mut i64,
1506 lossless: *mut bool,
1507 ) -> napi_status;
1508 /// Obtains an unsigned 64-bit integer from an ArkTS BigInt object.
1509 ///
1510 /// # Arguments
1511 ///
1512 /// * `env` - Current running virtual machine context.
1513 ///
1514 /// * `value` - ArkTS BigInt object.
1515 ///
1516 /// * `result` - Pointer points to the location where store the C unsigned 64-bit integer value.
1517 ///
1518 /// * `lossless` - Indicates whether the conversion is lossless. If lossless is true, the conversion is lossless,
1519 /// false otherwise.
1520 ///
1521 /// # Returns
1522 ///
1523 /// * Returns the function execution status.
1524 /// [`napi_ok`] If the function executed successfully.
1525 ///
1526 /// [`napi_invalid_arg`] If env, value, result or lossless is nullptr or word_count is larger than
1527 ///
1528 /// 2147483647.
1529 ///
1530 /// [`napi_bigint_expected`] If the 'value' is not an ArkTS bigint object.
1531 ///
1532 ///
1533 /// Available since API-level: 10
1534 pub fn napi_get_value_bigint_uint64(
1535 env: napi_env,
1536 value: napi_value,
1537 result: *mut u64,
1538 lossless: *mut bool,
1539 ) -> napi_status;
1540 /// Obtains the underlying 64-bit unsigned (uint64) byte data from an ArkTS BigInt object.
1541 ///
1542 /// # Arguments
1543 ///
1544 /// * `env` - Current running virtual machine context.
1545 ///
1546 /// * `value` - ArkTS BigInt object.
1547 ///
1548 /// * `sign_bit` - Sign bit of the BigInt. If sign_bit is 0, the BigInt is positive, otherwise it is negative.
1549 ///
1550 /// * `word_count` - The size of the words array.
1551 ///
1552 /// * `words` - C uint64 array in little-endian 64-bit format.
1553 ///
1554 /// # Returns
1555 ///
1556 /// * Returns the function execution status.
1557 /// [`napi_ok`] If the function executed successfully.
1558 ///
1559 /// [`napi_invalid_arg`] If env, value or word_count is nullptr or word_count is larger than 2147483647.
1560 ///
1561 /// [`napi_bigint_expected`] If the 'value' is not an ArkTS bigint object.
1562 ///
1563 ///
1564 /// Available since API-level: 10
1565 pub fn napi_get_value_bigint_words(
1566 env: napi_env,
1567 value: napi_value,
1568 sign_bit: *mut ::core::ffi::c_int,
1569 word_count: *mut usize,
1570 words: *mut u64,
1571 ) -> napi_status;
1572 /// Obtains the names of all properties of an ArkTS object.
1573 ///
1574 /// # Arguments
1575 ///
1576 /// * `env` - Current running virtual machine context.
1577 ///
1578 /// * `object` - ArkTS object.
1579 ///
1580 /// * `key_mode` - Key collection mode. If key_mode is napi_key_include_prototypes, the result includes properties on
1581 /// prototypes. If key_mode is napi_key_own_only, the result includes only properties directly on own
1582 /// object.
1583 ///
1584 /// * `key_filter` - Which properties to be collected.
1585 ///
1586 /// * `key_conversion` - Key conversion mode. If key_conversion is napi_key_keep_numbers, the numbered property keys
1587 /// will keep number type. If key_conversion is napi_key_numbers_to_strings, the numbered property
1588 /// keys will be convert to string type.
1589 ///
1590 /// * `result` - An array of ArkTS object that represent the property names of the object.
1591 ///
1592 /// # Returns
1593 ///
1594 /// * Returns the function execution status.
1595 /// [`napi_ok`] If the function executed successfully.
1596 ///
1597 /// [`napi_invalid_arg`] If env, object or result is nullptr;
1598 ///
1599 /// key_mode is not enumeration value of napi_key_collection_mode;
1600 ///
1601 /// key_conversion is not enumeration value of napi_key_conversion.
1602 ///
1603 /// [`napi_pending_exception`] If a ArkTS exception existed when the function was called.
1604 ///
1605 /// [`napi_object_expected`] If object is not object type and function type.
1606 ///
1607 ///
1608 /// Available since API-level: 10
1609 pub fn napi_get_all_property_names(
1610 env: napi_env,
1611 object: napi_value,
1612 key_mode: napi_key_collection_mode,
1613 key_filter: napi_key_filter,
1614 key_conversion: napi_key_conversion,
1615 result: *mut napi_value,
1616 ) -> napi_status;
1617 /// Associates data with the currently running environment.
1618 ///
1619 /// # Arguments
1620 ///
1621 /// * `env` - Current running virtual machine context.
1622 ///
1623 /// * `data` - Data item to bind with the 'env'.
1624 ///
1625 /// * `finalize_cb` - Optional native callback that will be triggered when 'env' is destroyed or this interface
1626 /// repeatedly calls.
1627 ///
1628 /// * `finalize_hint` - Optional contextual hint that is passed to the finalize callback.
1629 ///
1630 ///
1631 /// # Returns
1632 ///
1633 /// * Returns the function execution status.
1634 ///
1635 /// Available since API-level: 11
1636 #[cfg(feature = "api-11")]
1637 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
1638 pub fn napi_set_instance_data(
1639 env: napi_env,
1640 data: *mut ::core::ffi::c_void,
1641 finalize_cb: napi_finalize,
1642 finalize_hint: *mut ::core::ffi::c_void,
1643 ) -> napi_status;
1644 /// Retrieves the data that was previously associated with the currently running environment.
1645 ///
1646 /// # Arguments
1647 ///
1648 /// * `env` - Current running virtual machine context.
1649 ///
1650 /// * `data` - Data item is bound with the 'env'.
1651 ///
1652 ///
1653 /// # Returns
1654 ///
1655 /// * Returns the function execution status.
1656 ///
1657 /// Available since API-level: 11
1658 #[cfg(feature = "api-11")]
1659 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
1660 pub fn napi_get_instance_data(
1661 env: napi_env,
1662 data: *mut *mut ::core::ffi::c_void,
1663 ) -> napi_status;
1664 /// Detaches the underlying data from an 'ArrayBuffer' object. After the data is detached, you
1665 /// can operate the data in C/C++.
1666 ///
1667 /// # Arguments
1668 ///
1669 /// * `env` - Current running virtual machine context.
1670 ///
1671 /// * `arraybuffer` - ArkTS ArrayBuffer object.
1672 ///
1673 /// # Returns
1674 ///
1675 /// * Returns the function execution status.
1676 /// [`napi_ok`] If the function executed successfully.
1677 ///
1678 /// [`napi_invalid_arg`] If env or arraybuffer is nullptr, if 'arraybuffer' is not an ArrayBuffer object.
1679 ///
1680 /// [`napi_object_expected`] If the 'arraybuffer' is not an ArkTS object.
1681 ///
1682 ///
1683 /// Available since API-level: 10
1684 pub fn napi_detach_arraybuffer(env: napi_env, arraybuffer: napi_value) -> napi_status;
1685 /// Checks whether the given 'ArrayBuffer' has been detached.
1686 ///
1687 /// # Arguments
1688 ///
1689 /// * `env` - Current running virtual machine context.
1690 ///
1691 /// * `value` - ArkTS ArrayBuffer object.
1692 ///
1693 /// * `result` - Boolean value that is set to true if the 'value' has been detached, false otherwise.
1694 ///
1695 /// # Returns
1696 ///
1697 /// * Returns the function execution status.
1698 /// [`napi_ok`] If the function executed successfully.
1699 ///
1700 /// [`napi_invalid_arg`] If env, value or result is nullptr.
1701 ///
1702 ///
1703 /// Available since API-level: 10
1704 pub fn napi_is_detached_arraybuffer(
1705 env: napi_env,
1706 value: napi_value,
1707 result: *mut bool,
1708 ) -> napi_status;
1709 pub fn napi_type_tag_object(
1710 env: napi_env,
1711 value: napi_value,
1712 type_tag: *const napi_type_tag,
1713 ) -> napi_status;
1714 pub fn napi_check_object_type_tag(
1715 env: napi_env,
1716 value: napi_value,
1717 type_tag: *const napi_type_tag,
1718 result: *mut bool,
1719 ) -> napi_status;
1720 /// Freezes an ArkTS object. Once an object is frozen, its properties are immutable.
1721 ///
1722 /// # Arguments
1723 ///
1724 /// * `env` - Current running virtual machine context.
1725 ///
1726 /// * `object` - The given ArkTS object.
1727 ///
1728 /// # Returns
1729 ///
1730 /// * Returns the function execution status.
1731 /// [`napi_ok`] If the function executed successfully.
1732 ///
1733 /// [`napi_invalid_arg`] If env or object is nullptr.
1734 ///
1735 /// [`napi_pending_exception`] If a ArkTS exception existed when the function was called.
1736 ///
1737 ///
1738 /// Available since API-level: 10
1739 pub fn napi_object_freeze(env: napi_env, object: napi_value) -> napi_status;
1740 /// Seals an ArkTS object. Once an object is sealed, its properties cannot be added or deleted, but property
1741 /// values can be modified.
1742 ///
1743 /// # Arguments
1744 ///
1745 /// * `env` - Current running virtual machine context.
1746 ///
1747 /// * `object` - The given ArkTS object.
1748 ///
1749 /// # Returns
1750 ///
1751 /// * Returns the function execution status.
1752 /// [`napi_ok`] If the function executed successfully.
1753 ///
1754 /// [`napi_invalid_arg`] If env or object is nullptr.
1755 ///
1756 /// [`napi_pending_exception`] If a ArkTS exception existed when the function was called.
1757 ///
1758 ///
1759 /// Available since API-level: 10
1760 pub fn napi_object_seal(env: napi_env, object: napi_value) -> napi_status;
1761 /// Registers a native module.
1762 ///
1763 /// # Arguments
1764 ///
1765 /// * `mod` - Native module of type 'napi_module' to be registered.
1766 ///
1767 /// Available since API-level: 10
1768 pub fn napi_module_register(mod_: *mut napi_module);
1769 /// Raises a fatal error to terminate the process immediately.
1770 /// # Arguments
1771 ///
1772 /// * `location` - Optional location for the error occurrence.
1773 ///
1774 /// * `location_len` - The byte length of the location, or NAPI_AUTO_LENGTH if it is terminated by a null character.
1775 ///
1776 /// * `message` - The message associated with the error.
1777 ///
1778 /// * `message_len` - The byte length of the message, or NAPI_AUTO_LENGTH if it is terminated by a null character.
1779 ///
1780 ///
1781 /// Available since API-level: 10
1782 pub fn napi_fatal_error(
1783 location: *const ::core::ffi::c_char,
1784 location_len: usize,
1785 message: *const ::core::ffi::c_char,
1786 message_len: usize,
1787 ) -> !;
1788 /// Creates an asynchronous context. The capabilities related to 'async_hook' are not supported currently.
1789 ///
1790 /// # Arguments
1791 ///
1792 /// * `env` - Current running virtual machine context.
1793 ///
1794 /// * `async_resource` - Object associated with the async work that will be passed to possible 'async_hook'.
1795 ///
1796 /// * `async_resource_name` - Identifier for the kind of resource that is being provided for diagnostic information
1797 /// exposed by the async_hooks API.
1798 ///
1799 /// * `result` - The initialized async context.
1800 ///
1801 ///
1802 /// # Returns
1803 ///
1804 /// * Returns the function execution status.
1805 ///
1806 /// Available since API-level: 11
1807 #[cfg(feature = "api-11")]
1808 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
1809 pub fn napi_async_init(
1810 env: napi_env,
1811 async_resource: napi_value,
1812 async_resource_name: napi_value,
1813 result: *mut napi_async_context,
1814 ) -> napi_status;
1815 /// Destroys the previously created asynchronous context. The capabilities related to 'async_hook' are not
1816 /// supported currently.
1817 ///
1818 /// # Arguments
1819 ///
1820 /// * `env` - Current running virtual machine context.
1821 ///
1822 /// * `async_context` - The async context to be destroyed.
1823 ///
1824 ///
1825 /// # Returns
1826 ///
1827 /// * Returns the function execution status.
1828 ///
1829 /// Available since API-level: 11
1830 #[cfg(feature = "api-11")]
1831 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
1832 pub fn napi_async_destroy(env: napi_env, async_context: napi_async_context) -> napi_status;
1833 /// Allows a ArkTS function to be called in the asynchronous context. The capabilities related to 'async_hook'
1834 /// are not supported currently.
1835 /// # Arguments
1836 ///
1837 /// * `env` - Current running virtual machine context.
1838 ///
1839 /// * `async_context` - The context environment for the async operation.
1840 ///
1841 /// * `recv` - The 'this' pointer of the function.
1842 ///
1843 /// * `func` - ArkTS function to be called.
1844 ///
1845 /// * `argc` - Size of the argument array which is passed to 'func'.
1846 ///
1847 /// * `argv` - Argument array.
1848 ///
1849 /// * `result` - Result returned by the ArkTS function.
1850 ///
1851 ///
1852 /// # Returns
1853 ///
1854 /// * Returns the function execution status.
1855 ///
1856 /// Available since API-level: 11
1857 #[cfg(feature = "api-11")]
1858 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
1859 pub fn napi_make_callback(
1860 env: napi_env,
1861 async_context: napi_async_context,
1862 recv: napi_value,
1863 func: napi_value,
1864 argc: usize,
1865 argv: *const napi_value,
1866 result: *mut napi_value,
1867 ) -> napi_status;
1868 /// Creates an ArkTS ArrayBuffer object of the specified size.
1869 ///
1870 /// # Arguments
1871 ///
1872 /// * `env` - Current running virtual machine context.
1873 ///
1874 /// * `length` - Bytes size of the underlying arraybuffer.
1875 ///
1876 /// * `data` - Raw pointer to the underlying arraybuffer.
1877 ///
1878 /// * `result` - Created ArkTS ArrayBuffer object.
1879 ///
1880 /// # Returns
1881 ///
1882 /// * Returns the function execution status.
1883 /// [`napi_ok`] If the function executed successfully.
1884 ///
1885 /// [`napi_invalid_arg`] If env, data or result is nullptr, or length is larger than 2097152,
1886 /// or length is less than zero.
1887 ///
1888 ///
1889 /// Available since API-level: 10
1890 pub fn napi_create_buffer(
1891 env: napi_env,
1892 length: usize,
1893 data: *mut *mut ::core::ffi::c_void,
1894 result: *mut napi_value,
1895 ) -> napi_status;
1896 /// Creates an ArkTS ArrayBuffer object of the specified size and initializes it with the given data.
1897 ///
1898 /// # Arguments
1899 ///
1900 /// * `env` - Current running virtual machine context.n
1901 ///
1902 /// * `length` - Bytes size of the given data.
1903 ///
1904 /// * `data` - Given data.
1905 ///
1906 /// * `finalize_cb` - Optional native callback that can be used to free the given data when the ArkTS ArrayBuffer
1907 /// object has been garbage-collected.
1908 ///
1909 /// * `finalize_hint` - Optional contextual hint that is passed to the finalize callback.
1910 ///
1911 /// * `result` - Created ArkTS ArrayBuffer object.
1912 ///
1913 /// # Returns
1914 ///
1915 /// * Returns the function execution status.
1916 /// [`napi_ok`] If the function executed successfully.
1917 ///
1918 /// [`napi_invalid_arg`] If env, data or result is nullptr, or length is larger than 2097152,
1919 /// or length is less than or equal to zero.
1920 ///
1921 /// [`napi_pending_exception`] If a ArkTS exception existed when the function was called.
1922 ///
1923 ///
1924 /// Available since API-level: 10
1925 pub fn napi_create_external_buffer(
1926 env: napi_env,
1927 length: usize,
1928 data: *mut ::core::ffi::c_void,
1929 finalize_cb: napi_finalize,
1930 finalize_hint: *mut ::core::ffi::c_void,
1931 result: *mut napi_value,
1932 ) -> napi_status;
1933 /// Creates an ArkTS ArrayBuffer object of the specified size and initializes it with the given data.
1934 ///
1935 /// # Arguments
1936 ///
1937 /// * `env` - Current running virtual machine context.
1938 ///
1939 /// * `length` - Bytes size of the given data.
1940 ///
1941 /// * `data` - Given data.
1942 ///
1943 /// * `result_data` - Raw pointer to the underlying arraybuffer.
1944 ///
1945 /// * `result` - Created ArkTS ArrayBuffer object.
1946 ///
1947 /// # Returns
1948 ///
1949 /// * Returns the function execution status.
1950 /// [`napi_ok`] If the function executed successfully.
1951 ///
1952 /// [`napi_invalid_arg`] If env, data or result is nullptr, or length is larger than 2097152,
1953 /// or length is less than or equal to zero.
1954 ///
1955 ///
1956 /// Available since API-level: 10
1957 pub fn napi_create_buffer_copy(
1958 env: napi_env,
1959 length: usize,
1960 data: *const ::core::ffi::c_void,
1961 result_data: *mut *mut ::core::ffi::c_void,
1962 result: *mut napi_value,
1963 ) -> napi_status;
1964 /// Checks whether the given ArkTS value is a 'ArrayBuffer' object.
1965 ///
1966 /// # Arguments
1967 ///
1968 /// * `env` - Current running virtual machine context.
1969 ///
1970 /// * `value` - ArkTS ArrayBuffer object.
1971 ///
1972 /// * `result` - Boolean value that is set to true if the 'value' is a 'ArrayBuffer' object, false otherwise.
1973 ///
1974 /// # Returns
1975 ///
1976 /// * Returns the function execution status.
1977 /// [`napi_ok`] If the function executed successfully.
1978 ///
1979 /// [`napi_invalid_arg`] If env, value or result is nullptr.
1980 ///
1981 ///
1982 /// Available since API-level: 10
1983 pub fn napi_is_buffer(env: napi_env, value: napi_value, result: *mut bool) -> napi_status;
1984 /// Obtains the underlying data of 'ArrayBuffer' and its length.
1985 ///
1986 /// # Arguments
1987 ///
1988 /// * `env` - Current running virtual machine context.
1989 ///
1990 /// * `value` - ArkTS ArrayBuffer object.
1991 ///
1992 /// * `data` - Raw pointer to the underlying arraybuffer.
1993 ///
1994 /// * `length` - Bytes size of the underlying arraybuffer.
1995 ///
1996 /// # Returns
1997 ///
1998 /// * Returns the function execution status.
1999 /// [`napi_ok`] If the function executed successfully.
2000 ///
2001 /// [`napi_invalid_arg`] If env, value or result is nullptr.
2002 ///
2003 /// [`napi_arraybuffer_expected`] If the 'value' is not an ArkTS array buffer object.
2004 ///
2005 ///
2006 /// Available since API-level: 10
2007 pub fn napi_get_buffer_info(
2008 env: napi_env,
2009 value: napi_value,
2010 data: *mut *mut ::core::ffi::c_void,
2011 length: *mut usize,
2012 ) -> napi_status;
2013 pub fn napi_create_async_work(
2014 env: napi_env,
2015 async_resource: napi_value,
2016 async_resource_name: napi_value,
2017 execute: napi_async_execute_callback,
2018 complete: napi_async_complete_callback,
2019 data: *mut ::core::ffi::c_void,
2020 result: *mut napi_async_work,
2021 ) -> napi_status;
2022 pub fn napi_delete_async_work(env: napi_env, work: napi_async_work) -> napi_status;
2023 pub fn napi_queue_async_work(env: napi_env, work: napi_async_work) -> napi_status;
2024 pub fn napi_cancel_async_work(env: napi_env, work: napi_async_work) -> napi_status;
2025 pub fn napi_get_node_version(
2026 env: napi_env,
2027 version: *mut *const napi_node_version,
2028 ) -> napi_status;
2029 /// Obtains the current libuv loop instance.
2030 /// # Arguments
2031 ///
2032 /// * `env` - Current running virtual machine context.
2033 ///
2034 /// * `loop` - Libuv event loop.
2035 ///
2036 /// # Returns
2037 ///
2038 /// * Returns the function execution status.
2039 /// [`napi_ok`] If the function executed successfully.
2040 ///
2041 /// [`napi_invalid_arg`] If env or loop is nullptr.
2042 ///
2043 /// [`napi_generic_failure`] If env is invalid.
2044 ///
2045 ///
2046 /// Available since API-level: 10
2047 pub fn napi_get_uv_event_loop(env: napi_env, loop_: *mut *mut uv_loop_s) -> napi_status;
2048 /// Throws UncaughtException to ArkTS.
2049 /// # Arguments
2050 ///
2051 /// * `env` - Current running virtual machine context.
2052 ///
2053 /// * `err` - Error object which is passed to 'UncaughtException'.
2054 ///
2055 ///
2056 /// # Returns
2057 ///
2058 /// * Returns the function execution status.
2059 ///
2060 /// Available since API-level: 12
2061 #[cfg(feature = "api-12")]
2062 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
2063 pub fn napi_fatal_exception(env: napi_env, err: napi_value) -> napi_status;
2064 /// Registers a clean-up hook for releasing resources when the environment exits.
2065 ///
2066 /// # Arguments
2067 ///
2068 /// * `env` - Current running virtual machine context.
2069 ///
2070 /// * `fun` - Function pointer which will be triggered when environment is destroy.
2071 ///
2072 /// * `arg` - The argument is passed to the function pointer 'fun'.
2073 ///
2074 ///
2075 /// # Returns
2076 ///
2077 /// * Returns the function execution status.
2078 ///
2079 /// Available since API-level: 11
2080 #[cfg(feature = "api-11")]
2081 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
2082 pub fn napi_add_env_cleanup_hook(
2083 env: napi_env,
2084 fun: ::core::option::Option<unsafe extern "C" fn(arg: *mut ::core::ffi::c_void)>,
2085 arg: *mut ::core::ffi::c_void,
2086 ) -> napi_status;
2087 /// Unregisters the clean-up hook.
2088 ///
2089 /// # Arguments
2090 ///
2091 /// * `env` - Current running virtual machine context.
2092 ///
2093 /// * `fun` - Function pointer which will be triggered when environment is destroy.
2094 ///
2095 /// * `arg` - The argument is passed to the function pointer 'fun'.
2096 ///
2097 ///
2098 /// # Returns
2099 ///
2100 /// * Returns the function execution status.
2101 ///
2102 /// Available since API-level: 11
2103 #[cfg(feature = "api-11")]
2104 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
2105 pub fn napi_remove_env_cleanup_hook(
2106 env: napi_env,
2107 fun: ::core::option::Option<unsafe extern "C" fn(arg: *mut ::core::ffi::c_void)>,
2108 arg: *mut ::core::ffi::c_void,
2109 ) -> napi_status;
2110 /// Opens a callback scope. The capabilities related to 'async_hook' are not supported currently.
2111 /// # Arguments
2112 ///
2113 /// * `env` - Current running virtual machine context.
2114 ///
2115 /// * `resource_object` - The resource object to be passed to possible 'async_hook'.
2116 ///
2117 /// * `context` - The context environment for the async operation.
2118 ///
2119 /// * `result` - The generated callback scope.
2120 ///
2121 ///
2122 /// # Returns
2123 ///
2124 /// * Returns the function execution status.
2125 ///
2126 /// Available since API-level: 11
2127 #[cfg(feature = "api-11")]
2128 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
2129 pub fn napi_open_callback_scope(
2130 env: napi_env,
2131 resource_object: napi_value,
2132 context: napi_async_context,
2133 result: *mut napi_callback_scope,
2134 ) -> napi_status;
2135 /// Closes the callback scope. The capabilities related to 'async_hook' are not supported currently.
2136 ///
2137 /// # Arguments
2138 ///
2139 /// * `env` - Current running virtual machine context.
2140 ///
2141 /// * `scope` - The callback scope to be closed.
2142 ///
2143 ///
2144 /// # Returns
2145 ///
2146 /// * Returns the function execution status.
2147 ///
2148 /// Available since API-level: 11
2149 #[cfg(feature = "api-11")]
2150 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
2151 pub fn napi_close_callback_scope(env: napi_env, scope: napi_callback_scope) -> napi_status;
2152 /// Creates a thread-safe function.
2153 /// # Arguments
2154 ///
2155 /// * `env` - Current running virtual machine context.
2156 ///
2157 /// * `func` - ArkTS function to be called.
2158 ///
2159 /// * `async_resource` - An optional Object associated with the async work that will be passed to possible
2160 /// 'async_hooks'.
2161 ///
2162 /// * `async_resource_name` - An ArkTS string to provide an identifier for the kind of resource that is being
2163 /// provided for diagnostic information exposed by the `async_hooks` interface.
2164 ///
2165 /// * `max_queue_size` - Maximum size of the event queue in the thread-safe function.
2166 ///
2167 /// * `initial_thread_count` - Initial thread count of the thread-safe function.
2168 ///
2169 /// * `thread_finalize_data` - Data passed to the finalize callback.
2170 ///
2171 /// * `thread_finalize_cb` - Finalize callback function which will be triggered when the thread-safe function is
2172 /// released.
2173 ///
2174 /// * `context` - Optional data is passed to 'call_js_cb'.
2175 ///
2176 /// * `call_js_cb` - Callback function which will be triggered after 'napi_call_threadsafe_function()' is called.
2177 ///
2178 /// * `result` - The created thread-safe function.
2179 ///
2180 /// # Returns
2181 ///
2182 /// * Returns the function execution status.
2183 /// [`napi_ok`] If the function executed successfully.
2184 ///
2185 /// [`napi_invalid_arg`] If env, async_resource_name or result is nullptr; max_queue_size is less than 0;
2186 ///
2187 /// initial_thread_count is greater than 128 or less than 0; func and call_js_cb are
2188 ///
2189 /// nullptr at same time.
2190 ///
2191 /// [`napi_generic_failure`] If create thread-safe function failed.
2192 ///
2193 ///
2194 /// Available since API-level: 10
2195 pub fn napi_create_threadsafe_function(
2196 env: napi_env,
2197 func: napi_value,
2198 async_resource: napi_value,
2199 async_resource_name: napi_value,
2200 max_queue_size: usize,
2201 initial_thread_count: usize,
2202 thread_finalize_data: *mut ::core::ffi::c_void,
2203 thread_finalize_cb: napi_finalize,
2204 context: *mut ::core::ffi::c_void,
2205 call_js_cb: napi_threadsafe_function_call_js,
2206 result: *mut napi_threadsafe_function,
2207 ) -> napi_status;
2208 /// Obtains the context of a thread-safe function.
2209 /// # Arguments
2210 ///
2211 /// * `func` - The created thread-safe function.
2212 ///
2213 /// * `result` - Pointer pointer to the context of the thread-safe function.
2214 ///
2215 /// # Returns
2216 ///
2217 /// * Returns the function execution status.
2218 /// [`napi_ok`] If the function executed successfully.
2219 ///
2220 /// [`napi_invalid_arg`] If func or result is nullptr.
2221 ///
2222 ///
2223 /// Available since API-level: 10
2224 pub fn napi_get_threadsafe_function_context(
2225 func: napi_threadsafe_function,
2226 result: *mut *mut ::core::ffi::c_void,
2227 ) -> napi_status;
2228 /// Calls a thread-safe function.
2229 /// # Arguments
2230 ///
2231 /// * `func` - The created thread-safe function.
2232 ///
2233 /// * `data` - Data passed to the callback function 'call_js_cb' which is registered by calling
2234 /// 'napi_create_threadsafe_function()'.
2235 ///
2236 /// * `is_blocking` - If true, this function blocks until the event queue is not full. If false, return directly.
2237 ///
2238 /// # Returns
2239 ///
2240 /// * Returns the function execution status.
2241 /// [`napi_ok`] If the function executed successfully.
2242 ///
2243 /// [`napi_invalid_arg`] If func is nullptr.
2244 ///
2245 /// [`napi_queue_full`] If event queue is full.
2246 ///
2247 /// [`napi_closing`] If the thread-safe function is closing.
2248 ///
2249 /// [`napi_generic_failure`] If call thread-safe function failed.
2250 ///
2251 ///
2252 /// Available since API-level: 10
2253 pub fn napi_call_threadsafe_function(
2254 func: napi_threadsafe_function,
2255 data: *mut ::core::ffi::c_void,
2256 is_blocking: napi_threadsafe_function_call_mode,
2257 ) -> napi_status;
2258 /// Acquires a thread-safe function.
2259 /// # Arguments
2260 ///
2261 /// * `func` - The created thread-safe function.
2262 ///
2263 /// # Returns
2264 ///
2265 /// * Returns the function execution status.
2266 /// [`napi_ok`] If the function executed successfully.
2267 ///
2268 /// [`napi_invalid_arg`] If func is nullptr.
2269 ///
2270 /// [`napi_generic_failure`] If acquire thread-safe function failed.
2271 ///
2272 ///
2273 /// Available since API-level: 10
2274 pub fn napi_acquire_threadsafe_function(func: napi_threadsafe_function) -> napi_status;
2275 /// Releases a thread-safe function.
2276 /// # Arguments
2277 ///
2278 /// * `func` - The created thread-safe function.
2279 ///
2280 /// * `mode` - Value of mode can be either 'napi_tsfn_release' to indicate that no more calls should be made
2281 /// to the thread-safe function from current thread or 'napi_tsfn_abort' to indicate that the queue
2282 /// of the thread-safe function will be closed and 'napi_closing' will be return when calling
2283 /// 'napi_call_threadsafe_function()' under the circumstance.
2284 ///
2285 /// # Returns
2286 ///
2287 /// * Returns the function execution status.
2288 /// [`napi_ok`] If the function executed successfully.
2289 ///
2290 /// [`napi_invalid_arg`] If func is nullptr.
2291 ///
2292 /// [`napi_generic_failure`] If release thread-safe function failed.
2293 ///
2294 ///
2295 /// Available since API-level: 10
2296 pub fn napi_release_threadsafe_function(
2297 func: napi_threadsafe_function,
2298 mode: napi_threadsafe_function_release_mode,
2299 ) -> napi_status;
2300 /// Indicates that the event loop running on the main thread may exit before the thread-safe function
2301 /// is destroyed.
2302 /// # Arguments
2303 ///
2304 /// * `env` - Current running virtual machine context.
2305 ///
2306 /// * `func` - The created thread-safe function.
2307 ///
2308 /// # Returns
2309 ///
2310 /// * Returns the function execution status.
2311 /// [`napi_ok`] If the function executed successfully.
2312 ///
2313 /// [`napi_invalid_arg`] If env or func is nullptr.
2314 ///
2315 /// [`napi_generic_failure`] If unref thread-safe function failed.
2316 ///
2317 ///
2318 /// Available since API-level: 10
2319 pub fn napi_unref_threadsafe_function(
2320 env: napi_env,
2321 func: napi_threadsafe_function,
2322 ) -> napi_status;
2323 /// Indicates that the event loop running on the main thread should not exit until the thread-safe
2324 /// function is destroyed.
2325 /// # Arguments
2326 ///
2327 /// * `env` - Current running virtual machine context.
2328 ///
2329 /// * `func` - The created thread-safe function.
2330 ///
2331 /// # Returns
2332 ///
2333 /// * Returns the function execution status.
2334 /// [`napi_ok`] If the function executed successfully.
2335 ///
2336 /// [`napi_invalid_arg`] If env or func is nullptr.
2337 ///
2338 /// [`napi_generic_failure`] If ref thread-safe function failed.
2339 ///
2340 ///
2341 /// Available since API-level: 10
2342 pub fn napi_ref_threadsafe_function(
2343 env: napi_env,
2344 func: napi_threadsafe_function,
2345 ) -> napi_status;
2346 /// Registers an asynchronous clean-up hook for releasing resources when the environment exits.
2347 ///
2348 /// # Arguments
2349 ///
2350 /// * `env` - Current running virtual machine context.
2351 ///
2352 /// * `hook` - The function pointer to call at environment teardown.
2353 ///
2354 /// * `arg` - The pointer to pass to `hook` when it gets called.
2355 ///
2356 /// * `remove_handle` - Optional handle that refers to the asynchronous cleanup.
2357 ///
2358 ///
2359 /// # Returns
2360 ///
2361 /// * Returns the function execution status.
2362 ///
2363 /// Available since API-level: 11
2364 #[cfg(feature = "api-11")]
2365 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
2366 pub fn napi_add_async_cleanup_hook(
2367 env: napi_env,
2368 hook: napi_async_cleanup_hook,
2369 arg: *mut ::core::ffi::c_void,
2370 remove_handle: *mut napi_async_cleanup_hook_handle,
2371 ) -> napi_status;
2372 /// Unregisters the asynchronous clean-up hook.
2373 ///
2374 /// # Arguments
2375 ///
2376 /// * `remove_handle` - Optional handle that refers to the asynchronous cleanup.
2377 ///
2378 ///
2379 /// # Returns
2380 ///
2381 /// * Returns the function execution status.
2382 ///
2383 /// Available since API-level: 11
2384 #[cfg(feature = "api-11")]
2385 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
2386 pub fn napi_remove_async_cleanup_hook(
2387 remove_handle: napi_async_cleanup_hook_handle,
2388 ) -> napi_status;
2389 /// Obtains the absolute path of the location, from which the addon is loaded.
2390 ///
2391 /// # Arguments
2392 ///
2393 /// * `env` - Current running virtual machine context.
2394 ///
2395 /// * `result` - The absolute path of the location of the loaded addon.
2396 ///
2397 ///
2398 /// # Returns
2399 ///
2400 /// * Returns the function execution status.
2401 ///
2402 /// Available since API-level: 11
2403 #[cfg(feature = "api-11")]
2404 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
2405 pub fn node_api_get_module_file_name(
2406 env: napi_env,
2407 result: *mut *const ::core::ffi::c_char,
2408 ) -> napi_status;
2409 pub fn napi_run_script_path(
2410 env: napi_env,
2411 path: *const ::core::ffi::c_char,
2412 result: *mut napi_value,
2413 ) -> napi_status;
2414 pub fn napi_queue_async_work_with_qos(
2415 env: napi_env,
2416 work: napi_async_work,
2417 qos: napi_qos_t,
2418 ) -> napi_status;
2419 /// Loads an .abc file as a module. This API returns the namespace of the module.
2420 /// # Arguments
2421 ///
2422 /// * `env` - Current running virtual machine context.
2423 ///
2424 /// * `path` - Path of the .abc file or name of the module to load.
2425 ///
2426 /// * `result` - Result of the module object.
2427 ///
2428 ///
2429 /// # Returns
2430 ///
2431 /// * Returns the function execution status.
2432 ///
2433 /// Available since API-level: 11
2434 #[cfg(feature = "api-11")]
2435 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
2436 pub fn napi_load_module(
2437 env: napi_env,
2438 path: *const ::core::ffi::c_char,
2439 result: *mut napi_value,
2440 ) -> napi_status;
2441 /// Create ArkTS Object with initial properties given by descriptors, note that property key must be String, and
2442 /// must can not convert to element_index, also all keys must not duplicate.
2443 ///
2444 /// # Arguments
2445 ///
2446 /// * `env` - Current running virtual machine context.
2447 ///
2448 /// * `result` - The created ArkTS object.
2449 ///
2450 /// * `property_count` - Number of the property descriptors.
2451 ///
2452 /// * `properties` - Array of property descriptors which are expected to be applied to the ArkTS object.
2453 ///
2454 ///
2455 /// # Returns
2456 ///
2457 /// * Returns the function execution status.
2458 ///
2459 /// Available since API-level: 11
2460 #[cfg(feature = "api-11")]
2461 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
2462 pub fn napi_create_object_with_properties(
2463 env: napi_env,
2464 result: *mut napi_value,
2465 property_count: usize,
2466 properties: *const napi_property_descriptor,
2467 ) -> napi_status;
2468 /// Create ArkTS Object with initial properties given by keys and values, note that property key must be String,
2469 /// and must can not convert to element_index, also all keys must not duplicate.
2470 ///
2471 /// # Arguments
2472 ///
2473 /// * `env` - Current running virtual machine context.
2474 ///
2475 /// * `result` - The absolute path of the location of the loaded addon.
2476 ///
2477 /// * `property_count` - Number of the propertied which needs to be applied on the ArkTS object.
2478 ///
2479 /// * `keys` - Array of the keys of the properties.
2480 ///
2481 /// * `values` - Array of the values of the properties.
2482 ///
2483 ///
2484 /// # Returns
2485 ///
2486 /// * Returns the function execution status.
2487 ///
2488 /// Available since API-level: 11
2489 #[cfg(feature = "api-11")]
2490 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
2491 pub fn napi_create_object_with_named_properties(
2492 env: napi_env,
2493 result: *mut napi_value,
2494 property_count: usize,
2495 keys: *mut *const ::core::ffi::c_char,
2496 values: *const napi_value,
2497 ) -> napi_status;
2498 /// This API sets native properties to a object and converts this ArkTS object to native binding object.
2499 ///
2500 /// # Arguments
2501 ///
2502 /// * `env` - Current running virtual machine context.
2503 ///
2504 /// * `js_object` - The JavaScript value to coerce.
2505 ///
2506 /// * `detach_cb` - Native callback that can be used to detach the ArkTS object and the native object.
2507 ///
2508 /// * `attach_cb` - Native callback that can be used to bind the ArkTS object and the native object.
2509 ///
2510 /// * `native_object` - User-provided native instance to pass to thr detach callback and attach callback.
2511 ///
2512 /// * `hint` - Optional hint to pass to the detach callback and attach callback.
2513 ///
2514 ///
2515 /// # Returns
2516 ///
2517 /// * Return the function execution status.
2518 ///
2519 /// Available since API-level: 11
2520 #[cfg(feature = "api-11")]
2521 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
2522 pub fn napi_coerce_to_native_binding_object(
2523 env: napi_env,
2524 js_object: napi_value,
2525 detach_cb: napi_native_binding_detach_callback,
2526 attach_cb: napi_native_binding_attach_callback,
2527 native_object: *mut ::core::ffi::c_void,
2528 hint: *mut ::core::ffi::c_void,
2529 ) -> napi_status;
2530 /// The module is loaded through the NAPI. By default, the default object is exported from the module.
2531 ///
2532 /// # Arguments
2533 ///
2534 /// * `env` - Current running virtual machine context.
2535 ///
2536 /// * `path` - Path name of the module to be loaded, like
2537 /// * `module_info` - Path names of bundle and module, like com.example.application/entry.
2538 ///
2539 /// * `result` - Result of loading a module, which is an exported object of the module.
2540 ///
2541 ///
2542 /// # Returns
2543 ///
2544 /// * Returns the function execution status.
2545 ///
2546 /// Available since API-level: 12
2547 #[cfg(feature = "api-12")]
2548 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
2549 pub fn napi_load_module_with_info(
2550 env: napi_env,
2551 path: *const ::core::ffi::c_char,
2552 module_info: *const ::core::ffi::c_char,
2553 result: *mut napi_value,
2554 ) -> napi_status;
2555 /// Create the ark runtime.
2556 ///
2557 /// # Arguments
2558 ///
2559 /// * `env` - Indicates the ark runtime environment.
2560 ///
2561 ///
2562 /// # Returns
2563 ///
2564 /// * Return the function execution status.
2565 ///
2566 /// Available since API-level: 12
2567 #[cfg(feature = "api-12")]
2568 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
2569 pub fn napi_create_ark_runtime(env: *mut napi_env) -> napi_status;
2570 /// Destroy the ark runtime.
2571 ///
2572 /// # Arguments
2573 ///
2574 /// * `env` - Indicates the ark runtime environment.
2575 ///
2576 ///
2577 /// # Returns
2578 ///
2579 /// * Return the function execution status.
2580 ///
2581 /// Available since API-level: 12
2582 #[cfg(feature = "api-12")]
2583 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
2584 pub fn napi_destroy_ark_runtime(env: *mut napi_env) -> napi_status;
2585 /// Defines a sendable class.
2586 ///
2587 /// # Arguments
2588 ///
2589 /// * `env` - The environment that the API is invoked under.
2590 ///
2591 /// * `utf8name` - Name of the ArkTS constructor function.
2592 ///
2593 /// * `length` - The length of the utf8name in bytes, or NAPI_AUTO_LENGTH if it is null-terminated.
2594 ///
2595 /// * `constructor` - Callback function that handles constructing instances of the class.
2596 ///
2597 /// * `data` - Optional data to be passed to the constructor callback as the data property of the callback info.
2598 ///
2599 /// * `property_count` - Number of items in the properties array argument.
2600 ///
2601 /// * `properties` - Array of property descriptors describing static and instance data properties, accessors, and
2602 /// methods on the class. See napi_property_descriptor.
2603 ///
2604 /// * `parent` - A napi_value representing the Superclass.
2605 ///
2606 /// * `result` - A napi_value representing the constructor function for the class.
2607 ///
2608 ///
2609 /// # Returns
2610 ///
2611 /// * Return the function execution status.
2612 ///
2613 /// Available since API-level: 12
2614 #[cfg(feature = "api-12")]
2615 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
2616 pub fn napi_define_sendable_class(
2617 env: napi_env,
2618 utf8name: *const ::core::ffi::c_char,
2619 length: usize,
2620 constructor: napi_callback,
2621 data: *mut ::core::ffi::c_void,
2622 property_count: usize,
2623 properties: *const napi_property_descriptor,
2624 parent: napi_value,
2625 result: *mut napi_value,
2626 ) -> napi_status;
2627 /// Queries a napi_value to check if it is sendable.
2628 ///
2629 /// # Arguments
2630 ///
2631 /// * `env` - The environment that the API is invoked under.
2632 ///
2633 /// * `value` - The napi_value to be checked.
2634 ///
2635 /// * `result` - Boolean value that is set to true if napi_value is sendable, false otherwise.
2636 ///
2637 ///
2638 /// # Returns
2639 ///
2640 /// * Return the function execution status.
2641 ///
2642 /// Available since API-level: 12
2643 #[cfg(feature = "api-12")]
2644 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
2645 pub fn napi_is_sendable(env: napi_env, value: napi_value, result: *mut bool) -> napi_status;
2646 /// Defines a sendable object.
2647 ///
2648 /// # Arguments
2649 ///
2650 /// * `env` - The environment that the API is invoked under.
2651 ///
2652 /// * `property_count` - The count of object properties.
2653 ///
2654 /// * `properties` - Object properties.
2655 ///
2656 /// * `result` - The created sendable object.
2657 ///
2658 ///
2659 /// # Returns
2660 ///
2661 /// * Return the function execution status.
2662 ///
2663 /// Available since API-level: 12
2664 #[cfg(feature = "api-12")]
2665 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
2666 pub fn napi_create_sendable_object_with_properties(
2667 env: napi_env,
2668 property_count: usize,
2669 properties: *const napi_property_descriptor,
2670 result: *mut napi_value,
2671 ) -> napi_status;
2672 /// Wraps a native instance in a ArkTS object.
2673 /// # Arguments
2674 ///
2675 /// * `env` - The environment that the API is invoked under.
2676 ///
2677 /// * `js_object` - The ArkTS object that will be the wrapper for the native object.
2678 ///
2679 /// * `native_object` - The native instance that will be wrapped in the ArkTS object.
2680 ///
2681 /// * `finalize_cb` - Optional native callback that can be used to free the native instance when the ArkTS object
2682 /// has been garbage-collected.
2683 ///
2684 /// * `async_finalizer` - A bool value to determine that finalize_cb execute async or not.
2685 ///
2686 /// * `finalize_hint` - Optional contextual hint that is passed to the finalize callback.
2687 ///
2688 /// * `native_binding_size` - The size of native binding.
2689 ///
2690 /// * `result` - Optional reference to the wrapped object.
2691 ///
2692 ///
2693 /// # Returns
2694 ///
2695 /// * Returns the function execution status.
2696 /// [`napi_ok`] If the function executedd successfully.
2697 ///
2698 /// [`napi_invalid_arg`] If the param env, js_object or native_object is nullptr.
2699 ///
2700 /// [`napi_object_expected`] If the param js_object is not an ArkTS Object or Function.
2701 ///
2702 /// [`napi_pending_exception`] If have uncaught exception, or exception occured in execution.
2703 ///
2704 ///
2705 /// Available since API-level: 18
2706 #[cfg(feature = "api-18")]
2707 #[cfg_attr(docsrs, doc(cfg(feature = "api-18")))]
2708 pub fn napi_wrap_enhance(
2709 env: napi_env,
2710 js_object: napi_value,
2711 native_object: *mut ::core::ffi::c_void,
2712 finalize_cb: napi_finalize,
2713 async_finalizer: bool,
2714 finalize_hint: *mut ::core::ffi::c_void,
2715 native_binding_size: usize,
2716 result: *mut napi_ref,
2717 ) -> napi_status;
2718 /// Wraps a native instance in a ArkTS object.
2719 ///
2720 /// # Arguments
2721 ///
2722 /// * `env` - The environment that the API is invoked under.
2723 ///
2724 /// * `js_object` - The ArkTS object that will be the wrapper for the native object.
2725 ///
2726 /// * `native_object` - The native instance that will be wrapped in the ArkTS object.
2727 ///
2728 /// * `finalize_cb` - Optional native callback that can be used to free the native instance when the ArkTS object
2729 /// has been garbage-collected.
2730 ///
2731 /// * `finalize_hint` - Optional contextual hint that is passed to the finalize callback.
2732 ///
2733 ///
2734 /// # Returns
2735 ///
2736 /// * Return the function execution status.
2737 ///
2738 /// Available since API-level: 12
2739 #[cfg(feature = "api-12")]
2740 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
2741 pub fn napi_wrap_sendable(
2742 env: napi_env,
2743 js_object: napi_value,
2744 native_object: *mut ::core::ffi::c_void,
2745 finalize_cb: napi_finalize,
2746 finalize_hint: *mut ::core::ffi::c_void,
2747 ) -> napi_status;
2748 /// Wraps a native instance in a ArkTS object.
2749 ///
2750 /// # Arguments
2751 ///
2752 /// * `env` - The environment that the API is invoked under.
2753 ///
2754 /// * `js_object` - The ArkTS object that will be the wrapper for the native object.
2755 ///
2756 /// * `native_object` - The native instance that will be wrapped in the ArkTS object.
2757 ///
2758 /// * `finalize_cb` - Optional native callback that can be used to free the native instance when the ArkTS object
2759 /// has been garbage-collected.
2760 ///
2761 /// * `finalize_hint` - Optional contextual hint that is passed to the finalize callback.
2762 ///
2763 /// * `native_binding_size` - The size of native binding.
2764 ///
2765 ///
2766 /// # Returns
2767 ///
2768 /// * Return the function execution status.
2769 ///
2770 /// Available since API-level: 12
2771 #[cfg(feature = "api-12")]
2772 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
2773 pub fn napi_wrap_sendable_with_size(
2774 env: napi_env,
2775 js_object: napi_value,
2776 native_object: *mut ::core::ffi::c_void,
2777 finalize_cb: napi_finalize,
2778 finalize_hint: *mut ::core::ffi::c_void,
2779 native_binding_size: usize,
2780 ) -> napi_status;
2781 /// Retrieves a native instance that was previously wrapped in a ArkTS object.
2782 ///
2783 /// # Arguments
2784 ///
2785 /// * `env` - The environment that the API is invoked under.
2786 ///
2787 /// * `js_object` - The object associated with the native instance.
2788 ///
2789 /// * `result` - Pointer to the wrapped native instance.
2790 ///
2791 ///
2792 /// # Returns
2793 ///
2794 /// * Return the function execution status.
2795 ///
2796 /// Available since API-level: 12
2797 #[cfg(feature = "api-12")]
2798 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
2799 pub fn napi_unwrap_sendable(
2800 env: napi_env,
2801 js_object: napi_value,
2802 result: *mut *mut ::core::ffi::c_void,
2803 ) -> napi_status;
2804 /// Retrieves a native instance that was previously wrapped in a ArkTS object and removes the wrapping.
2805 ///
2806 /// # Arguments
2807 ///
2808 /// * `env` - The environment that the API is invoked under.
2809 ///
2810 /// * `js_object` - The object associated with the native instance.
2811 ///
2812 /// * `result` - Pointer to the wrapped native instance.
2813 ///
2814 ///
2815 /// # Returns
2816 ///
2817 /// * Return the function execution status.
2818 ///
2819 /// Available since API-level: 12
2820 #[cfg(feature = "api-12")]
2821 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
2822 pub fn napi_remove_wrap_sendable(
2823 env: napi_env,
2824 js_object: napi_value,
2825 result: *mut *mut ::core::ffi::c_void,
2826 ) -> napi_status;
2827 /// Create a sendable array.
2828 ///
2829 /// # Arguments
2830 ///
2831 /// * `env` - The environment that the API is invoked under.
2832 ///
2833 /// * `result` - A napi_value representing a sendable array.
2834 ///
2835 ///
2836 /// # Returns
2837 ///
2838 /// * Return the function execution status.
2839 ///
2840 /// Available since API-level: 12
2841 #[cfg(feature = "api-12")]
2842 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
2843 pub fn napi_create_sendable_array(env: napi_env, result: *mut napi_value) -> napi_status;
2844 /// Create a sendable array with length.
2845 ///
2846 /// # Arguments
2847 ///
2848 /// * `env` - The environment that the API is invoked under.
2849 ///
2850 /// * `length` - The initial length of the sendable array.
2851 ///
2852 /// * `result` - A napi_value representing a sendable array.
2853 ///
2854 ///
2855 /// # Returns
2856 ///
2857 /// * Return the function execution status.
2858 ///
2859 /// Available since API-level: 12
2860 #[cfg(feature = "api-12")]
2861 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
2862 pub fn napi_create_sendable_array_with_length(
2863 env: napi_env,
2864 length: usize,
2865 result: *mut napi_value,
2866 ) -> napi_status;
2867 /// Create a sendable arraybuffer.
2868 ///
2869 /// # Arguments
2870 ///
2871 /// * `env` - The environment that the API is invoked under.
2872 ///
2873 /// * `byte_length` - The length in bytes of the sendable arraybuffer to create.
2874 ///
2875 /// * `data` - Pointer to the underlying byte buffer of the sendable arraybuffer.
2876 ///
2877 /// * `result` - A napi_value representing a sendable arraybuffer.
2878 ///
2879 ///
2880 /// # Returns
2881 ///
2882 /// * Return the function execution status.
2883 ///
2884 /// Available since API-level: 12
2885 #[cfg(feature = "api-12")]
2886 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
2887 pub fn napi_create_sendable_arraybuffer(
2888 env: napi_env,
2889 byte_length: usize,
2890 data: *mut *mut ::core::ffi::c_void,
2891 result: *mut napi_value,
2892 ) -> napi_status;
2893 /// Create a sendable typedarray.
2894 ///
2895 /// # Arguments
2896 ///
2897 /// * `env` - The environment that the API is invoked under.
2898 ///
2899 /// * `type` - Scalar datatype of the elements within the sendable typedarray.
2900 ///
2901 /// * `length` - Number of elements in the typedarray.
2902 ///
2903 /// * `arraybuffer` - Sendable arraybuffer underlying the sendable typedarray.
2904 ///
2905 /// * `byte_offset` - The byte offset within the sendable arraybuffer from which to start projecting the
2906 /// sendable typedarray.
2907 ///
2908 /// * `result` - A napi_value representing a sendable typedarray.
2909 ///
2910 ///
2911 /// # Returns
2912 ///
2913 /// * Return the function execution status.
2914 ///
2915 /// Available since API-level: 12
2916 #[cfg(feature = "api-12")]
2917 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
2918 pub fn napi_create_sendable_typedarray(
2919 env: napi_env,
2920 type_: napi_typedarray_type,
2921 length: usize,
2922 arraybuffer: napi_value,
2923 byte_offset: usize,
2924 result: *mut napi_value,
2925 ) -> napi_status;
2926 /// Run the event loop by the given env and running mode in current thread.
2927 ///
2928 /// Support to run the native event loop in an asynchronous native thread with the specified running mode.
2929 ///
2930 /// # Arguments
2931 ///
2932 /// * `env` - Current running virtual machine context.
2933 ///
2934 /// * `mode` - Indicates the running mode of the native event loop.
2935 ///
2936 ///
2937 /// # Returns
2938 ///
2939 /// * Return the function execution status.
2940 ///
2941 /// Available since API-level: 12
2942 #[cfg(feature = "api-12")]
2943 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
2944 pub fn napi_run_event_loop(env: napi_env, mode: napi_event_mode) -> napi_status;
2945 /// Stop the event loop in current thread.
2946 ///
2947 /// Support to stop the running event loop in current native thread.
2948 ///
2949 /// # Arguments
2950 ///
2951 /// * `env` - Current running virtual machine context.
2952 ///
2953 ///
2954 /// # Returns
2955 ///
2956 /// * Return the function execution status.
2957 ///
2958 /// Available since API-level: 12
2959 #[cfg(feature = "api-12")]
2960 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
2961 pub fn napi_stop_event_loop(env: napi_env) -> napi_status;
2962 /// Serialize a ArkTS object.
2963 ///
2964 /// # Arguments
2965 ///
2966 /// * `env` - Current running virtual machine context.
2967 ///
2968 /// * `object` - The ArkTS object to serialize.
2969 ///
2970 /// * `transfer_list` - List of data to transfer in transfer mode.
2971 ///
2972 /// * `clone_list` - List of Sendable data to transfer in clone mode.
2973 ///
2974 /// * `result` - Serialization result of the ArkTS object.
2975 ///
2976 ///
2977 /// # Returns
2978 ///
2979 /// * Returns the function execution status.
2980 ///
2981 /// Available since API-level: 12
2982 #[cfg(feature = "api-12")]
2983 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
2984 pub fn napi_serialize(
2985 env: napi_env,
2986 object: napi_value,
2987 transfer_list: napi_value,
2988 clone_list: napi_value,
2989 result: *mut *mut ::core::ffi::c_void,
2990 ) -> napi_status;
2991 /// Restore serialization data to a ArkTS object.
2992 ///
2993 /// # Arguments
2994 ///
2995 /// * `env` - Current running virtual machine context.
2996 ///
2997 /// * `buffer` - Data to deserialize.
2998 ///
2999 /// * `object` - ArkTS object obtained by deserialization.
3000 ///
3001 ///
3002 /// # Returns
3003 ///
3004 /// * Returns the function execution status.
3005 ///
3006 /// Available since API-level: 12
3007 #[cfg(feature = "api-12")]
3008 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
3009 pub fn napi_deserialize(
3010 env: napi_env,
3011 buffer: *mut ::core::ffi::c_void,
3012 object: *mut napi_value,
3013 ) -> napi_status;
3014 /// Delete serialization data.
3015 ///
3016 /// # Arguments
3017 ///
3018 /// * `env` - Current running virtual machine context.
3019 ///
3020 /// * `buffer` - Data to delete.
3021 ///
3022 ///
3023 /// # Returns
3024 ///
3025 /// * Returns the function execution status.
3026 ///
3027 /// Available since API-level: 12
3028 #[cfg(feature = "api-12")]
3029 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
3030 pub fn napi_delete_serialization_data(
3031 env: napi_env,
3032 buffer: *mut ::core::ffi::c_void,
3033 ) -> napi_status;
3034 /// Dispatch a task with specified priority from a native thread to an ArkTS thread, the task will execute
3035 /// the given thread safe function.
3036 ///
3037 /// # Arguments
3038 ///
3039 /// * `func` - Indicates the thread safe function.
3040 ///
3041 /// * `data` - Indicates the data anticipated to be transferred to the ArkTS thread.
3042 ///
3043 /// * `priority` - Indicates the priority of the task dispatched.
3044 ///
3045 /// * `isTail` - Indicates the way of the task dispatched into the native event queue. When "isTail" is true,
3046 /// the task will be dispatched to the tail of the native event queue. Conversely, when "isTail" is false, the
3047 /// tasks will be dispatched to the head of the native event queue.
3048 ///
3049 ///
3050 /// # Returns
3051 ///
3052 /// * Return the function execution status.
3053 ///
3054 /// Available since API-level: 12
3055 #[cfg(feature = "api-12")]
3056 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
3057 pub fn napi_call_threadsafe_function_with_priority(
3058 func: napi_threadsafe_function,
3059 data: *mut ::core::ffi::c_void,
3060 priority: napi_task_priority,
3061 isTail: bool,
3062 ) -> napi_status;
3063}