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 const NAPI_AUTO_LENGTH: usize = usize::MAX;
7pub use ohos_sys_opaque_types::{napi_env, napi_value};
8
9pub const NAPI_VERSION: u32 = 8;
10pub const NAPI_VERSION_EXPERIMENTAL: u32 = 2147483647;
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>;
333#[repr(C)]
334pub struct napi_critical_scope__ {
335 _unused: [u8; 0],
336}
337/// Native critical scope provides a scope within that an ArkTS string buffer cache can be obtained.
338///
339/// Available since API-level: 21
340#[cfg(feature = "api-21")]
341#[cfg_attr(docsrs, doc(cfg(feature = "api-21")))]
342pub type napi_critical_scope = *mut napi_critical_scope__;
343#[repr(C)]
344pub struct napi_strong_ref__ {
345 _unused: [u8; 0],
346}
347/// Native strong reference of an ArkTS object.
348///
349/// Available since API-level: 21
350#[cfg(feature = "api-21")]
351#[cfg_attr(docsrs, doc(cfg(feature = "api-21")))]
352pub type napi_strong_ref = *mut napi_strong_ref__;
353#[repr(C)]
354pub struct napi_sendable_ref__ {
355 _unused: [u8; 0],
356}
357/// Native strong sendable reference of an sendable ArkTS object.
358///
359///
360/// Available since API-level: 22
361#[cfg(feature = "api-22")]
362#[cfg_attr(docsrs, doc(cfg(feature = "api-22")))]
363pub type napi_sendable_ref = *mut napi_sendable_ref__;
364/// Native finalize callback is utilized to recycle native object resource.
365///
366///
367/// Available since API-level: 22
368#[cfg(feature = "api-22")]
369#[cfg_attr(docsrs, doc(cfg(feature = "api-22")))]
370pub type napi_finalize_callback = ::core::option::Option<
371 unsafe extern "C" fn(
372 finalize_data: *mut ::core::ffi::c_void,
373 finalize_hint: *mut ::core::ffi::c_void,
374 ),
375>;
376extern "C" {
377 /// Obtains the napi_extended_error_info struct, which contains the latest error information.
378 ///
379 /// # Arguments
380 ///
381 /// * `env` - Current running virtual machine context.
382 ///
383 /// * `result` - The error info about the error.
384 ///
385 ///
386 /// # Returns
387 ///
388 /// * Returns the function execution status.
389 /// [`napi_ok`] If the function executed successfully.
390 ///
391 /// [`napi_invalid_arg`] If env or result is nullptr.
392 ///
393 ///
394 /// Available since API-level: 10
395 pub fn napi_get_last_error_info(
396 env: napi_env,
397 result: *mut *const napi_extended_error_info,
398 ) -> napi_status;
399 /// Obtains the ArkTS undefined value.
400 /// # Arguments
401 ///
402 /// * `env` - Current running virtual machine context.
403 ///
404 /// * `result` - The ArkTS undefined value.
405 ///
406 ///
407 /// # Returns
408 ///
409 /// * Returns the function execution status.
410 /// [`napi_ok`] If the function executed successfully.
411 ///
412 /// [`napi_invalid_arg`] If the parameter env and(or) result is nullptr.
413 ///
414 ///
415 /// Available since API-level: 10
416 pub fn napi_get_undefined(env: napi_env, result: *mut napi_value) -> napi_status;
417 /// Obtains the ArkTS null value.
418 /// # Arguments
419 ///
420 /// * `env` - Current running virtual machine context.
421 ///
422 /// * `result` - The ArkTS null value.
423 ///
424 ///
425 /// # Returns
426 ///
427 /// * Returns the function execution status.
428 /// [`napi_ok`] If the function executed successfully.
429 ///
430 /// [`napi_invalid_arg`] If the param env and(or) result is nullptr.
431 ///
432 ///
433 /// Available since API-level: 10
434 pub fn napi_get_null(env: napi_env, result: *mut napi_value) -> napi_status;
435 /// Obtains the ArkTS global object.
436 /// # Arguments
437 ///
438 /// * `env` - Current running virtual machine context.
439 ///
440 /// * `result` - The ArkTS global Object.
441 ///
442 ///
443 /// # Returns
444 ///
445 /// * Returns the function execution status.
446 /// [`napi_ok`] If the function executed successfully.
447 ///
448 /// [`napi_invalid_arg`] If the param env and(or) result is nullptr.
449 ///
450 ///
451 /// Available since API-level: 10
452 pub fn napi_get_global(env: napi_env, result: *mut napi_value) -> napi_status;
453 /// Obtains the ArkTS singleton value corresponding to given C primitive boolean value.
454 /// # Arguments
455 ///
456 /// * `env` - Current running virtual machine context.
457 ///
458 /// * `value` - C primitive boolean value.
459 ///
460 /// * `result` - The ArkTS singleton value equivalent of C primitive boolean value.
461 ///
462 ///
463 /// # Returns
464 ///
465 /// * Returns the function execution status.
466 /// [`napi_ok`] If the function executed successfully.
467 ///
468 /// [`napi_invalid_arg`] If the param env and(or) result is nullptr.
469 ///
470 ///
471 /// Available since API-level: 10
472 pub fn napi_get_boolean(env: napi_env, value: bool, result: *mut napi_value) -> napi_status;
473 /// Creates a default ArkTS object.
474 /// # Arguments
475 ///
476 /// * `env` - Current running virtual machine context.
477 ///
478 /// * `result` - napi_value representing an ArkTS object.
479 ///
480 ///
481 /// # Returns
482 ///
483 /// * Returns the function execution status.
484 /// [`napi_ok`] If the function executed successfully.
485 ///
486 /// [`napi_invalid_arg`] If the param env and(or) result is nullptr.
487 ///
488 ///
489 /// Available since API-level: 10
490 pub fn napi_create_object(env: napi_env, result: *mut napi_value) -> napi_status;
491 /// Creates an ArkTS array.
492 /// # Arguments
493 ///
494 /// * `env` - Current running virtual machine context.
495 ///
496 /// * `result` - napi_value representing an ArkTS Array.
497 ///
498 ///
499 /// # Returns
500 ///
501 /// * Returns the function execution status.
502 /// [`napi_ok`] If the function executed successfully.
503 ///
504 /// [`napi_invalid_arg`] If the param env and(or) result is nullptr.
505 ///
506 ///
507 /// Available since API-level: 10
508 pub fn napi_create_array(env: napi_env, result: *mut napi_value) -> napi_status;
509 /// Creates an ArkTS array of the specified length.
510 /// # Arguments
511 ///
512 /// * `env` - Current running virtual machine context.
513 ///
514 /// * `length` - The length of the Array.
515 ///
516 /// * `result` - napi_value representing an ArkTS Array.
517 ///
518 ///
519 /// # Returns
520 ///
521 /// * Returns the function execution status.
522 /// [`napi_ok`] If the function executed successfully.
523 ///
524 /// [`napi_invalid_arg`] If the param env and(or) result is nullptr.
525 ///
526 ///
527 /// Available since API-level: 10
528 pub fn napi_create_array_with_length(
529 env: napi_env,
530 length: usize,
531 result: *mut napi_value,
532 ) -> napi_status;
533 /// Creates an ArkTS number from C double data.
534 /// # Arguments
535 ///
536 /// * `env` - Current running virtual machine context.
537 ///
538 /// * `value` - The double value to be represented in ArkTS.
539 ///
540 /// * `result` - A napi_value representing an ArkTS number.
541 ///
542 ///
543 /// # Returns
544 ///
545 /// * Returns the function execution status.
546 /// [`napi_ok`] If the function executed successfully.
547 ///
548 /// [`napi_invalid_arg`] If the param env and(or) result is nullptr.
549 ///
550 ///
551 /// Available since API-level: 10
552 pub fn napi_create_double(env: napi_env, value: f64, result: *mut napi_value) -> napi_status;
553 /// Creates an ArkTS number from C int32_t data.
554 /// # Arguments
555 ///
556 /// * `env` - Current running virtual machine context.
557 ///
558 /// * `value` - The int32 value to be represented in ArkTS.
559 ///
560 /// * `result` - A napi_value representing an ArkTS number.
561 ///
562 ///
563 /// # Returns
564 ///
565 /// * Returns the function execution status.
566 /// [`napi_ok`] If the function executed successfully.
567 ///
568 /// [`napi_invalid_arg`] If the param env and(or) result is nullptr.
569 ///
570 ///
571 /// Available since API-level: 10
572 pub fn napi_create_int32(env: napi_env, value: i32, result: *mut napi_value) -> napi_status;
573 /// Creates an ArkTS number from C uint32_t data.
574 /// # Arguments
575 ///
576 /// * `env` - Current running virtual machine context.
577 ///
578 /// * `value` - The uint32 value to be represented in ArkTS.
579 ///
580 /// * `result` - A napi_value representing an ArkTS number.
581 ///
582 ///
583 /// # Returns
584 ///
585 /// * Returns the function execution status.
586 /// [`napi_ok`] If the function executed successfully.
587 ///
588 /// [`napi_invalid_arg`] If the param env and(or) result is nullptr.
589 ///
590 ///
591 /// Available since API-level: 10
592 pub fn napi_create_uint32(env: napi_env, value: u32, result: *mut napi_value) -> napi_status;
593 /// Creates an ArkTS number from C int64_t data.
594 /// # Arguments
595 ///
596 /// * `env` - Current running virtual machine context.
597 ///
598 /// * `value` - The int64 value to be represented in ArkTS.
599 ///
600 /// * `result` - A napi_value representing an ArkTS number.
601 ///
602 ///
603 /// # Returns
604 ///
605 /// * Returns the function execution status.
606 /// [`napi_ok`] If the function executed successfully.
607 ///
608 /// [`napi_invalid_arg`] If the param env and(or) result is nullptr.
609 ///
610 ///
611 /// Available since API-level: 10
612 pub fn napi_create_int64(env: napi_env, value: i64, result: *mut napi_value) -> napi_status;
613 /// Creates an ArkTS string from an ISO-8859-1-encoded C string.
614 /// # Arguments
615 ///
616 /// * `env` - Current running virtual machine context.
617 ///
618 /// * `str` - C string encoded in ISO-8859-1-encoded format.
619 ///
620 /// * `length` - The length of the C string 'str'.
621 ///
622 /// * `result` - Result of the ArkTS string from the ISO-8859-1-encoded C string.
623 ///
624 ///
625 /// # Returns
626 ///
627 /// * Returns the function execution status.
628 /// [`napi_ok`] If the function executed successfully.
629 ///
630 /// [`napi_invalid_arg`] If the param env, str and(or) result is nullptr.
631 ///
632 ///
633 /// Available since API-level: 10
634 pub fn napi_create_string_latin1(
635 env: napi_env,
636 str_: *const ::core::ffi::c_char,
637 length: usize,
638 result: *mut napi_value,
639 ) -> napi_status;
640 /// Creates an ArkTS string from a UTF8-encoded C string.
641 /// # Arguments
642 ///
643 /// * `env` - Current running virtual machine context.
644 ///
645 /// * `str` - C string encoded in UTF8 format.
646 ///
647 /// * `length` - The length of the C string 'str'.
648 ///
649 /// * `result` - Result of the ArkTS string from the UTF8-encoded C string.
650 ///
651 ///
652 /// # Returns
653 ///
654 /// * Returns the function execution status.
655 /// [`napi_ok`] If the function executed successfully.
656 ///
657 /// [`napi_invalid_arg`] If the param env, str and(or) result is nullptr.
658 ///
659 ///
660 /// Available since API-level: 10
661 pub fn napi_create_string_utf8(
662 env: napi_env,
663 str_: *const ::core::ffi::c_char,
664 length: usize,
665 result: *mut napi_value,
666 ) -> napi_status;
667 pub fn napi_create_string_utf16(
668 env: napi_env,
669 str_: *const char16_t,
670 length: usize,
671 result: *mut napi_value,
672 ) -> napi_status;
673 /// Creates an ArkTS symbol.
674 /// # Arguments
675 ///
676 /// * `env` - Current running virtual machine context.
677 ///
678 /// * `description` - Optional napi_value representing an ArkTS string to describe the symbol.
679 ///
680 /// * `result` - A napi_value representing an ArkTS symbol.
681 ///
682 ///
683 /// # Returns
684 ///
685 /// * Returns the function execution status.
686 /// [`napi_ok`] If the function executed successfully.
687 ///
688 /// [`napi_invalid_arg`] If the param env and(or) result is nullptr;
689 ///
690 /// If the param description is not nullptr and is not an ArkTS String.
691 ///
692 ///
693 /// Available since API-level: 10
694 pub fn napi_create_symbol(
695 env: napi_env,
696 description: napi_value,
697 result: *mut napi_value,
698 ) -> napi_status;
699 /// Create an ArkTS function. This is the primary mechanism to call back into native code from ArkTS.
700 /// # Arguments
701 ///
702 /// * `env` - Current running virtual machine context.
703 ///
704 /// * `utf8name` - The visible within ArkTS as the new function's name property.
705 ///
706 /// * `length` - The length oh the utf8name, or NAPI_AUTO_LENGTH if it is null-terminated.
707 ///
708 /// * `cb` - The native function which should be called when this function object is called.
709 ///
710 /// * `data` - User-provided data context. This will be passed back into the function when invoked.
711 ///
712 /// * `result` - The newly created ArkTS function.
713 ///
714 ///
715 /// # Returns
716 ///
717 /// * Returns the function execution status.
718 /// [`napi_ok`] If the function executed successfully.
719 ///
720 /// [`napi_invalid_arg`] If the param env, cb and(or) result is nullptr.
721 ///
722 /// [`napi_pending_exception`] There is an uncaught exception occurred before(in) execution.
723 ///
724 ///
725 /// Available since API-level: 10
726 pub fn napi_create_function(
727 env: napi_env,
728 utf8name: *const ::core::ffi::c_char,
729 length: usize,
730 cb: napi_callback,
731 data: *mut ::core::ffi::c_void,
732 result: *mut napi_value,
733 ) -> napi_status;
734 /// Creates an ArkTS Error with text information.
735 /// # Arguments
736 ///
737 /// * `env` - Current running virtual machine context.
738 ///
739 /// * `code` - Optional error code to set on the error.
740 ///
741 /// * `msg` - napi_value representing the EcmaScript string to be associated with the error.
742 ///
743 /// * `result` - napi_value representing the error created.
744 ///
745 ///
746 /// # Returns
747 ///
748 /// * Returns the function execution status.
749 /// [`napi_ok`] If the function executed successfully.
750 ///
751 /// [`napi_invalid_arg`] If env, msg or result is nullptr, code is not string and number type or msg is
752 ///
753 /// not a string type.
754 ///
755 ///
756 /// Available since API-level: 10
757 pub fn napi_create_error(
758 env: napi_env,
759 code: napi_value,
760 msg: napi_value,
761 result: *mut napi_value,
762 ) -> napi_status;
763 /// Creates an ArkTS TypeError with text information.
764 /// # Arguments
765 ///
766 /// * `env` - Current running virtual machine context.
767 ///
768 /// * `code` - Optional error code to set on the error.
769 ///
770 /// * `msg` - napi_value representing the EcmaScript string to be associated with the error.
771 ///
772 /// * `result` - napi_value representing the error created.
773 ///
774 ///
775 /// # Returns
776 ///
777 /// * Returns the function execution status.
778 /// [`napi_ok`] If the function executed successfully.
779 ///
780 /// [`napi_invalid_arg`] If env, msg or result is nullptr, code is not string and number type or msg is
781 ///
782 /// not a string type.
783 ///
784 ///
785 /// Available since API-level: 10
786 pub fn napi_create_type_error(
787 env: napi_env,
788 code: napi_value,
789 msg: napi_value,
790 result: *mut napi_value,
791 ) -> napi_status;
792 /// Creates an ArkTS RangeError with text information.
793 /// # Arguments
794 ///
795 /// * `env` - Current running virtual machine context.
796 ///
797 /// * `code` - Optional error code to set on the error.
798 ///
799 /// * `msg` - napi_value representing the EcmaScript string to be associated with the error.
800 ///
801 /// * `result` - napi_value representing the error created.
802 ///
803 ///
804 /// # Returns
805 ///
806 /// * Returns the function execution status.
807 /// [`napi_ok`] If the function executed successfully.
808 ///
809 /// [`napi_invalid_arg`] If env, msg or result is nullptr, code is not string and number type or msg is
810 ///
811 /// not a string type.
812 ///
813 ///
814 /// Available since API-level: 10
815 pub fn napi_create_range_error(
816 env: napi_env,
817 code: napi_value,
818 msg: napi_value,
819 result: *mut napi_value,
820 ) -> napi_status;
821 /// Similar to typeof operation, support external value, detects null as a separate type.
822 /// # Arguments
823 ///
824 /// * `env` - Current running virtual machine context.
825 ///
826 /// * `value` - The ArkTS value whose type expects to query.
827 ///
828 /// * `result` - The type of ArkTS value.
829 ///
830 ///
831 /// # Returns
832 ///
833 /// * Returns the function execution status.
834 /// [`napi_ok`] If the function executed successfully.
835 ///
836 /// [`napi_invalid_arg`] If the param env, value and(or) result is nullptr.
837 ///
838 ///
839 /// Available since API-level: 10
840 pub fn napi_typeof(
841 env: napi_env,
842 value: napi_value,
843 result: *mut napi_valuetype,
844 ) -> napi_status;
845 /// Obtains the double value corresponding to the given ArkTS value.
846 /// # Arguments
847 ///
848 /// * `env` - Current running virtual machine context.
849 ///
850 /// * `value` - ArkTS number.
851 ///
852 /// * `result` - The C primitive equivalent of ArkTS value as double.
853 ///
854 ///
855 /// # Returns
856 ///
857 /// * Returns the function execution status.
858 /// [`napi_ok`] If the function executed successfully.
859 ///
860 /// [`napi_invalid_arg`] If the param env, value and(or) result is nullptr.
861 ///
862 /// [`napi_number_expected`] If a non-number ArkTS value passed in it.
863 ///
864 ///
865 /// Available since API-level: 10
866 pub fn napi_get_value_double(env: napi_env, value: napi_value, result: *mut f64)
867 -> napi_status;
868 /// Obtains the int32_t value corresponding to the given ArkTS value.
869 /// # Arguments
870 ///
871 /// * `env` - Current running virtual machine context.
872 ///
873 /// * `value` - ArkTS number.
874 ///
875 /// * `result` - The C primitive equivalent of ArkTS value as int32_t.
876 ///
877 ///
878 /// # Returns
879 ///
880 /// * Returns the function execution status.
881 /// [`napi_ok`] If the function executed successfully.
882 ///
883 /// [`napi_invalid_arg`] If the param env, value and(or) result is nullptr.
884 ///
885 /// [`napi_number_expected`] If a non-number ArkTS value passed in it.
886 ///
887 ///
888 /// Available since API-level: 10
889 pub fn napi_get_value_int32(env: napi_env, value: napi_value, result: *mut i32) -> napi_status;
890 /// Obtains the uint32_t value corresponding to the given ArkTS value.
891 /// # Arguments
892 ///
893 /// * `env` - Current running virtual machine context.
894 ///
895 /// * `value` - ArkTS number.
896 ///
897 /// * `result` - The C primitive equivalent of ArkTS value as uint32_t.
898 ///
899 ///
900 /// # Returns
901 ///
902 /// * Returns the function execution status.
903 /// [`napi_ok`] If the function executed successfully.
904 ///
905 /// [`napi_invalid_arg`] If the param env, value and(or) result is nullptr.
906 ///
907 /// [`napi_number_expected`] If a non-number ArkTS value passed in it.
908 ///
909 ///
910 /// Available since API-level: 10
911 pub fn napi_get_value_uint32(env: napi_env, value: napi_value, result: *mut u32)
912 -> napi_status;
913 /// Obtains the int64_t value corresponding to the given ArkTS value.
914 /// # Arguments
915 ///
916 /// * `env` - Current running virtual machine context.
917 ///
918 /// * `value` - ArkTS number.
919 ///
920 /// * `result` - The C primitive equivalent of ArkTS value as int64_t.
921 ///
922 ///
923 /// # Returns
924 ///
925 /// * Returns the function execution status.
926 /// [`napi_ok`] If the function executed successfully.
927 ///
928 /// [`napi_invalid_arg`] If the param env, value and(or) result is nullptr.
929 ///
930 /// [`napi_number_expected`] If a non-number ArkTS value passed in it.
931 ///
932 ///
933 /// Available since API-level: 10
934 pub fn napi_get_value_int64(env: napi_env, value: napi_value, result: *mut i64) -> napi_status;
935 /// Obtains the C Boolean equivalent of an ArkTS Boolean value.
936 /// # Arguments
937 ///
938 /// * `env` - Current running virtual machine context.
939 ///
940 /// * `value` - A napi_value representing ArkTS Boolean.
941 ///
942 /// * `result` - The C boolean equivalent of the ArkTS Boolean.
943 ///
944 ///
945 /// # Returns
946 ///
947 /// * Returns the function execution status.
948 /// [`napi_ok`] If the function executed successfully.
949 ///
950 /// [`napi_invalid_arg`] If the param env, value and(or) result is nullptr.
951 ///
952 /// [`napi_boolean_expected`] If a non-boolean ArkTS value passed in it.
953 ///
954 ///
955 /// Available since API-level: 10
956 pub fn napi_get_value_bool(env: napi_env, value: napi_value, result: *mut bool) -> napi_status;
957 /// Obtains the ISO-8859-1-encoded string corresponding to the given ArkTS value.
958 /// # Arguments
959 ///
960 /// * `env` - Current running virtual machine context.
961 ///
962 /// * `value` - ArkTS string.
963 ///
964 /// * `buf` - Destination buffer that will be filled with the provided ISO-8859-1-encoded string.
965 ///
966 /// * `bufsize` - The size of the buffer 'buf'.
967 ///
968 /// * `result` - The length of the string in ISO-8859-1-encoded format.
969 ///
970 ///
971 /// # Returns
972 ///
973 /// * Returns the function execution status.
974 /// [`napi_ok`] If the function executed successfully.
975 ///
976 /// [`napi_invalid_arg`] If the param env and(or) value is nullptr;
977 ///
978 /// If the param buf and result both are nullptr.
979 ///
980 /// [`napi_string_expected`] If a non-string ArkTS value passed in it.
981 ///
982 ///
983 /// Available since API-level: 10
984 pub fn napi_get_value_string_latin1(
985 env: napi_env,
986 value: napi_value,
987 buf: *mut ::core::ffi::c_char,
988 bufsize: usize,
989 result: *mut usize,
990 ) -> napi_status;
991 /// Obtains the UTF8-encoded string corresponding to the given ArkTS value.
992 /// # Arguments
993 ///
994 /// * `env` - Current running virtual machine context.
995 ///
996 /// * `value` - ArkTS string.
997 ///
998 /// * `buf` - Destination buffer that will be filled with the provided UTF8-encoded string.
999 ///
1000 /// * `bufsize` - The size of the buffer 'buf'.
1001 ///
1002 /// * `result` - The length of the string in UTF8-encoded format.
1003 ///
1004 ///
1005 /// # Returns
1006 ///
1007 /// * Returns the function execution status.
1008 /// [`napi_ok`] If the function executed successfully.
1009 ///
1010 /// [`napi_invalid_arg`] If the param env and(or) value is nullptr;
1011 ///
1012 /// If the param buf and result both are nullptr.
1013 ///
1014 /// [`napi_string_expected`] If a non-string ArkTS value passed in it.
1015 ///
1016 ///
1017 /// Available since API-level: 10
1018 pub fn napi_get_value_string_utf8(
1019 env: napi_env,
1020 value: napi_value,
1021 buf: *mut ::core::ffi::c_char,
1022 bufsize: usize,
1023 result: *mut usize,
1024 ) -> napi_status;
1025 pub fn napi_get_value_string_utf16(
1026 env: napi_env,
1027 value: napi_value,
1028 buf: *mut char16_t,
1029 bufsize: usize,
1030 result: *mut usize,
1031 ) -> napi_status;
1032 /// Coerce the given ArkTS value to an ArkTS boolean value.
1033 /// # Arguments
1034 ///
1035 /// * `env` - Current running virtual machine context.
1036 ///
1037 /// * `value` - The ArkTS value to coerce.
1038 ///
1039 /// * `result` - The coerced ArkTS boolean value.
1040 ///
1041 ///
1042 /// # Returns
1043 ///
1044 /// * Returns the function execution status.
1045 /// [`napi_ok`] If the function executed successfully.
1046 ///
1047 /// [`napi_invalid_arg`] If the param env, value and(or) result is nullptr.
1048 ///
1049 ///
1050 /// Available since API-level: 10
1051 pub fn napi_coerce_to_bool(
1052 env: napi_env,
1053 value: napi_value,
1054 result: *mut napi_value,
1055 ) -> napi_status;
1056 /// Coerce the given ArkTS value to an ArkTS number value.
1057 /// # Arguments
1058 ///
1059 /// * `env` - Current running virtual machine context.
1060 ///
1061 /// * `value` - The ArkTS value to coerce.
1062 ///
1063 /// * `result` - The coerced ArkTS number value.
1064 ///
1065 ///
1066 /// # Returns
1067 ///
1068 /// * Returns the function execution status.
1069 /// [`napi_ok`] If the function executed successfully.
1070 ///
1071 /// [`napi_invalid_arg`] If the param env, value and(or) result is nullptr.
1072 ///
1073 ///
1074 /// Available since API-level: 10
1075 pub fn napi_coerce_to_number(
1076 env: napi_env,
1077 value: napi_value,
1078 result: *mut napi_value,
1079 ) -> napi_status;
1080 /// Coerce the given ArkTS value to an ArkTS object value.
1081 /// # Arguments
1082 ///
1083 /// * `env` - Current running virtual machine context.
1084 ///
1085 /// * `value` - The ArkTS value to coerce.
1086 ///
1087 /// * `result` - The coerced ArkTS object value.
1088 ///
1089 ///
1090 /// # Returns
1091 ///
1092 /// * Returns the function execution status.
1093 /// [`napi_ok`] If the function executed successfully.
1094 ///
1095 /// [`napi_invalid_arg`] If the param env, value and(or) result is nullptr.
1096 ///
1097 ///
1098 /// Available since API-level: 10
1099 pub fn napi_coerce_to_object(
1100 env: napi_env,
1101 value: napi_value,
1102 result: *mut napi_value,
1103 ) -> napi_status;
1104 /// Coerce the given ArkTS value to an ArkTS string value.
1105 /// # Arguments
1106 ///
1107 /// * `env` - Current running virtual machine context.
1108 ///
1109 /// * `value` - The ArkTS value to coerce.
1110 ///
1111 /// * `result` - The coerced ArkTS string value.
1112 ///
1113 ///
1114 /// # Returns
1115 ///
1116 /// * Returns the function execution status.
1117 /// [`napi_ok`] If the function executed successfully.
1118 ///
1119 /// [`napi_invalid_arg`] If the param env, value and(or) result is nullptr.
1120 ///
1121 ///
1122 /// Available since API-level: 10
1123 pub fn napi_coerce_to_string(
1124 env: napi_env,
1125 value: napi_value,
1126 result: *mut napi_value,
1127 ) -> napi_status;
1128 /// Obtains the prototype of an ArkTS object.
1129 /// # Arguments
1130 ///
1131 /// * `env` - Current running virtual machine context.
1132 ///
1133 /// * `object` - The napi_value representing an ArkTS Object whose prototype to return.
1134 ///
1135 /// * `result` - A napi_value representing prototype of the object.
1136 ///
1137 ///
1138 /// # Returns
1139 ///
1140 /// * Returns the function execution status.
1141 /// [`napi_ok`] If the function executed successfully.
1142 ///
1143 /// [`napi_invalid_arg`] If the param env, object or result is nullptr;
1144 ///
1145 /// [`napi_pending_exception`] There is an uncaught exception occurred before(in) execution.
1146 ///
1147 ///
1148 /// Available since API-level: 10
1149 pub fn napi_get_prototype(
1150 env: napi_env,
1151 object: napi_value,
1152 result: *mut napi_value,
1153 ) -> napi_status;
1154 /// Obtains the names of the enumerable properties of object as an Array of Strings. The keys that are symbols
1155 /// will not be included.
1156 /// # Arguments
1157 ///
1158 /// * `env` - Current running virtual machine context.
1159 ///
1160 /// * `object` - The ArkTS object from which the property is retrieved.
1161 ///
1162 /// * `result` - An ArkTS Array that contains the attribute names of the object.
1163 ///
1164 ///
1165 /// # Returns
1166 ///
1167 /// * Returns the function execution status.
1168 /// [`napi_ok`] If the function executed successfully.
1169 ///
1170 /// [`napi_invalid_arg`] If the param env, value and(or) result is nullptr.
1171 ///
1172 /// [`napi_object_expected`] If the param object is not an ArkTS Object.
1173 ///
1174 ///
1175 /// Available since API-level: 10
1176 pub fn napi_get_property_names(
1177 env: napi_env,
1178 object: napi_value,
1179 result: *mut napi_value,
1180 ) -> napi_status;
1181 /// Set a property on the given ArkTS Object.
1182 /// # Arguments
1183 ///
1184 /// * `env` - Current running virtual machine context.
1185 ///
1186 /// * `object` - The ArkTS object.
1187 ///
1188 /// * `key` - The name of the property to set.
1189 ///
1190 /// * `value` - The property value.
1191 ///
1192 ///
1193 /// # Returns
1194 ///
1195 /// * Returns the function execution status.
1196 /// [`napi_ok`] If the function executed successfully.
1197 ///
1198 /// [`napi_invalid_arg`] If the param env, object, key and(or) value is nullptr.
1199 ///
1200 /// [`napi_object_expected`] If the param object is not an ArkTS Object.
1201 ///
1202 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1203 ///
1204 ///
1205 /// Available since API-level: 10
1206 pub fn napi_set_property(
1207 env: napi_env,
1208 object: napi_value,
1209 key: napi_value,
1210 value: napi_value,
1211 ) -> napi_status;
1212 /// Check if the given ArkTS Object has the named property or not.
1213 /// # Arguments
1214 ///
1215 /// * `env` - Current running virtual machine context.
1216 ///
1217 /// * `object` - The ArkTS object.
1218 ///
1219 /// * `key` - The name of the property to check.
1220 ///
1221 /// * `result` - Whether the property exists on the object or not.
1222 ///
1223 ///
1224 /// # Returns
1225 ///
1226 /// * Returns the function execution status.
1227 /// [`napi_ok`] If the function executed successfully.
1228 ///
1229 /// [`napi_invalid_arg`] If the param env, object, key and(or) result is nullptr.
1230 ///
1231 /// [`napi_object_expected`] If the param object is not an ArkTS Object.
1232 ///
1233 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1234 ///
1235 ///
1236 /// Available since API-level: 10
1237 pub fn napi_has_property(
1238 env: napi_env,
1239 object: napi_value,
1240 key: napi_value,
1241 result: *mut bool,
1242 ) -> napi_status;
1243 /// Get the requests property of the given ArkTS Object.
1244 /// # Arguments
1245 ///
1246 /// * `env` - Current running virtual machine context.
1247 ///
1248 /// * `object` - The ArkTS object.
1249 ///
1250 /// * `key` - The name of the property to get.
1251 ///
1252 /// * `result` - The value of the property.
1253 ///
1254 ///
1255 /// # Returns
1256 ///
1257 /// * Returns the function execution status.
1258 /// [`napi_ok`] If the function executed successfully.
1259 ///
1260 /// [`napi_invalid_arg`] If the param env, object, key and(or) result is nullptr.
1261 ///
1262 /// [`napi_object_expected`] If the param object is not an ArkTS Object.
1263 ///
1264 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1265 ///
1266 ///
1267 /// Available since API-level: 10
1268 pub fn napi_get_property(
1269 env: napi_env,
1270 object: napi_value,
1271 key: napi_value,
1272 result: *mut napi_value,
1273 ) -> napi_status;
1274 /// Delete the named property of the given ArkTS Object.
1275 /// # Arguments
1276 ///
1277 /// * `env` - Current running virtual machine context.
1278 ///
1279 /// * `object` - The ArkTS object.
1280 ///
1281 /// * `key` - The name of the property to delete.
1282 ///
1283 /// * `result` - Whether the execution is succeed or not. Can optionally be ignored by passing nullptr.
1284 ///
1285 ///
1286 /// # Returns
1287 ///
1288 /// * Returns the function execution status.
1289 /// [`napi_ok`] If the function executed successfully.
1290 ///
1291 /// [`napi_invalid_arg`] If the param env, object and(or) key is nullptr.
1292 ///
1293 /// [`napi_object_expected`] If the param object is not an ArkTS Object.
1294 ///
1295 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1296 ///
1297 ///
1298 /// Available since API-level: 10
1299 pub fn napi_delete_property(
1300 env: napi_env,
1301 object: napi_value,
1302 key: napi_value,
1303 result: *mut bool,
1304 ) -> napi_status;
1305 /// Check if the given ArkTS Object has the named own property or not.
1306 /// # Arguments
1307 ///
1308 /// * `env` - Current running virtual machine context.
1309 ///
1310 /// * `object` - The ArkTS object.
1311 ///
1312 /// * `key` - The name of the property to check.
1313 ///
1314 /// * `result` - Whether the own property exists on the object or not.
1315 ///
1316 ///
1317 /// # Returns
1318 ///
1319 /// * Returns the function execution status.
1320 /// [`napi_ok`] If the function executed successfully.
1321 ///
1322 /// [`napi_invalid_arg`] If the param env, object, key and(or) result is nullptr.
1323 ///
1324 /// [`napi_object_expected`] If the param object is not an ArkTS Object.
1325 ///
1326 /// [`napi_pending_exception`] If have uncaught exception, or exception occurs in execution.
1327 ///
1328 ///
1329 /// Available since API-level: 10
1330 pub fn napi_has_own_property(
1331 env: napi_env,
1332 object: napi_value,
1333 key: napi_value,
1334 result: *mut bool,
1335 ) -> napi_status;
1336 /// Set a property on the given ArkTS Object.
1337 /// # Arguments
1338 ///
1339 /// * `env` - Current running virtual machine context.
1340 ///
1341 /// * `object` - The ArkTS object.
1342 ///
1343 /// * `utf8name` - The name of the property to set.
1344 ///
1345 /// * `value` - The property value.
1346 ///
1347 ///
1348 /// # Returns
1349 ///
1350 /// * Returns the function execution status.
1351 /// [`napi_ok`] If the function executed successfully.
1352 ///
1353 /// [`napi_invalid_arg`] If the param env, object, utf8name and(or) value is nullptr.
1354 ///
1355 /// [`napi_object_expected`] If the param object is not an ArkTS Object.
1356 ///
1357 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1358 ///
1359 ///
1360 /// Available since API-level: 10
1361 pub fn napi_set_named_property(
1362 env: napi_env,
1363 object: napi_value,
1364 utf8name: *const ::core::ffi::c_char,
1365 value: napi_value,
1366 ) -> napi_status;
1367 /// Check if the given ArkTS Object has the named property or not.
1368 /// # Arguments
1369 ///
1370 /// * `env` - Current running virtual machine context.
1371 ///
1372 /// * `object` - The ArkTS object.
1373 ///
1374 /// * `utf8name` - The name of the property to check.
1375 ///
1376 /// * `result` - Whether the property exists on the object or not.
1377 ///
1378 ///
1379 /// # Returns
1380 ///
1381 /// * Returns the function execution status.
1382 /// [`napi_ok`] If the function executed successfully.
1383 ///
1384 /// [`napi_invalid_arg`] If the param env, object, utf8name and(or) result is nullptr.
1385 ///
1386 /// [`napi_object_expected`] If the param object is not an ArkTS Object.
1387 ///
1388 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1389 ///
1390 ///
1391 /// Available since API-level: 10
1392 pub fn napi_has_named_property(
1393 env: napi_env,
1394 object: napi_value,
1395 utf8name: *const ::core::ffi::c_char,
1396 result: *mut bool,
1397 ) -> napi_status;
1398 /// Get the requests property of the given ArkTS Object.
1399 /// # Arguments
1400 ///
1401 /// * `env` - Current running virtual machine context.
1402 ///
1403 /// * `object` - The ArkTS object.
1404 ///
1405 /// * `utf8name` - The name of the property to get.
1406 ///
1407 /// * `result` - The value of the property.
1408 ///
1409 ///
1410 /// # Returns
1411 ///
1412 /// * Returns the function execution status.
1413 /// [`napi_ok`] If the function executed successfully.
1414 ///
1415 /// [`napi_invalid_arg`] If the param env, object, utf8name and(or) result is nullptr.
1416 ///
1417 /// [`napi_object_expected`] If the param object is not an ArkTS Object.
1418 ///
1419 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1420 ///
1421 ///
1422 /// Available since API-level: 10
1423 pub fn napi_get_named_property(
1424 env: napi_env,
1425 object: napi_value,
1426 utf8name: *const ::core::ffi::c_char,
1427 result: *mut napi_value,
1428 ) -> napi_status;
1429 /// Set a element on the given ArkTS Array.
1430 /// # Arguments
1431 ///
1432 /// * `env` - Current running virtual machine context.
1433 ///
1434 /// * `object` - The ArkTS Array.
1435 ///
1436 /// * `index` - The index of the element to set.
1437 ///
1438 /// * `value` - The element value.
1439 ///
1440 ///
1441 /// # Returns
1442 ///
1443 /// * Returns the function execution status.
1444 /// [`napi_ok`] If the function executed successfully.
1445 ///
1446 /// [`napi_invalid_arg`] If the param env, object and(or) value is nullptr.
1447 ///
1448 /// [`napi_object_expected`] If the param object is not an ArkTS Object.
1449 ///
1450 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1451 ///
1452 ///
1453 /// Available since API-level: 10
1454 pub fn napi_set_element(
1455 env: napi_env,
1456 object: napi_value,
1457 index: u32,
1458 value: napi_value,
1459 ) -> napi_status;
1460 /// Check if the given ArkTS Array has an element at the requested index.
1461 /// # Arguments
1462 ///
1463 /// * `env` - Current running virtual machine context.
1464 ///
1465 /// * `object` - The ArkTS Array.
1466 ///
1467 /// * `index` - The name of the property to check.
1468 ///
1469 /// * `result` - Whether the property exists on the Array or not.
1470 ///
1471 ///
1472 /// # Returns
1473 ///
1474 /// * Returns the function execution status.
1475 /// [`napi_ok`] If the function executed successfully.
1476 ///
1477 /// [`napi_invalid_arg`] If the param env, object and(or) result is nullptr.
1478 ///
1479 /// [`napi_object_expected`] If the param object is not an ArkTS Object.
1480 ///
1481 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1482 ///
1483 ///
1484 /// Available since API-level: 10
1485 pub fn napi_has_element(
1486 env: napi_env,
1487 object: napi_value,
1488 index: u32,
1489 result: *mut bool,
1490 ) -> napi_status;
1491 /// Get the requests element of the given ArkTS Array.
1492 /// # Arguments
1493 ///
1494 /// * `env` - Current running virtual machine context.
1495 ///
1496 /// * `object` - The ArkTS Array.
1497 ///
1498 /// * `index` - The index of the element to get.
1499 ///
1500 /// * `result` - The value of the element.
1501 ///
1502 ///
1503 /// # Returns
1504 ///
1505 /// * Returns the function execution status.
1506 /// [`napi_ok`] If the function executed successfully.
1507 ///
1508 /// [`napi_invalid_arg`] If the param env, object and(or) result is nullptr.
1509 ///
1510 /// [`napi_object_expected`] If the param object is not an ArkTS Object.
1511 ///
1512 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1513 ///
1514 ///
1515 /// Available since API-level: 10
1516 pub fn napi_get_element(
1517 env: napi_env,
1518 object: napi_value,
1519 index: u32,
1520 result: *mut napi_value,
1521 ) -> napi_status;
1522 /// Delete the special index from the given ArkTS Array.
1523 /// # Arguments
1524 ///
1525 /// * `env` - Current running virtual machine context.
1526 ///
1527 /// * `object` - The ArkTS Array.
1528 ///
1529 /// * `index` - The index of the element to delete.
1530 ///
1531 /// * `result` - Whether the execution is succeed or not. Can optionally be ignored by passing nullptr.
1532 ///
1533 ///
1534 /// # Returns
1535 ///
1536 /// * Returns the function execution status.
1537 /// [`napi_ok`] If the function executed successfully.
1538 ///
1539 /// [`napi_invalid_arg`] If the param env, object and(or) key is nullptr.
1540 ///
1541 /// [`napi_object_expected`] If the param object is not an ArkTS Object.
1542 ///
1543 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1544 ///
1545 ///
1546 /// Available since API-level: 10
1547 pub fn napi_delete_element(
1548 env: napi_env,
1549 object: napi_value,
1550 index: u32,
1551 result: *mut bool,
1552 ) -> napi_status;
1553 /// Efficient define multiple properties on the given ArkTS Object by napi_property_descriptor.
1554 /// # Arguments
1555 ///
1556 /// * `env` - Current running virtual machine context.
1557 ///
1558 /// * `object` - The ArkTS Object.
1559 ///
1560 /// * `property_count` - The count of elements in the properties array.
1561 ///
1562 /// * `properties` - The properties array.
1563 ///
1564 ///
1565 /// # Returns
1566 ///
1567 /// * Returns the function execution status.
1568 /// [`napi_ok`] If the function executed successfully.
1569 ///
1570 /// [`napi_invalid_arg`] If the param env, object and(or) properties is nullptr.
1571 ///
1572 /// [`napi_object_expected`] If the param object is not an ArkTS Object.
1573 ///
1574 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1575 ///
1576 ///
1577 /// Available since API-level: 10
1578 pub fn napi_define_properties(
1579 env: napi_env,
1580 object: napi_value,
1581 property_count: usize,
1582 properties: *const napi_property_descriptor,
1583 ) -> napi_status;
1584 /// Checks if the ArkTS value is an ArkTS Array.
1585 /// # Arguments
1586 ///
1587 /// * `env` - Current running virtual machine context.
1588 ///
1589 /// * `value` - The ArkTS value to check.
1590 ///
1591 /// * `result` - Whether the given ArkTS value is an ArkTS Array.
1592 ///
1593 ///
1594 /// # Returns
1595 ///
1596 /// * Returns the function execution status.
1597 /// [`napi_ok`] If the function executed successfully.
1598 ///
1599 /// [`napi_invalid_arg`] If the param env, value and(or) result is nullptr.
1600 ///
1601 ///
1602 /// Available since API-level: 10
1603 pub fn napi_is_array(env: napi_env, value: napi_value, result: *mut bool) -> napi_status;
1604 /// Obtains the array length.
1605 /// # Arguments
1606 ///
1607 /// * `env` - Current running virtual machine context.
1608 ///
1609 /// * `value` - The napi_value representing the ArkTS Array being queried.
1610 ///
1611 /// * `result` - The length of the array.
1612 ///
1613 ///
1614 /// # Returns
1615 ///
1616 /// * Returns the function execution status.
1617 /// [`napi_ok`] If the function executed successfully.
1618 ///
1619 /// [`napi_invalid_arg`] If the param env, value and(or) result is nullptr;
1620 ///
1621 /// [`napi_pending_exception`] There is an uncaught exception occurred before(in) execution.
1622 ///
1623 ///
1624 /// Available since API-level: 10
1625 pub fn napi_get_array_length(env: napi_env, value: napi_value, result: *mut u32)
1626 -> napi_status;
1627 /// Checks if the two ArkTS values are equal.
1628 /// # Arguments
1629 ///
1630 /// * `env` - Current running virtual machine context.
1631 ///
1632 /// * `lhs` - The ArkTS value to check.
1633 ///
1634 /// * `rhs` - The ArkTS value to check against.
1635 ///
1636 /// * `result` - Whether the two given ArkTS values are equal.
1637 ///
1638 ///
1639 /// # Returns
1640 ///
1641 /// * Returns the function execution status.
1642 /// [`napi_ok`] If the function executed successfully.
1643 ///
1644 /// [`napi_invalid_arg`] If the param env, value and(or) result is nullptr.
1645 ///
1646 ///
1647 /// Available since API-level: 10
1648 pub fn napi_strict_equals(
1649 env: napi_env,
1650 lhs: napi_value,
1651 rhs: napi_value,
1652 result: *mut bool,
1653 ) -> napi_status;
1654 /// Invoke an ArkTS function. This is the primary mechanism to call back into JavaScript.
1655 /// # Arguments
1656 ///
1657 /// * `env` - Current running virtual machine context.
1658 ///
1659 /// * `recv` - The this value passed to the called function
1660 ///
1661 /// * `func` - The ArkTS function to be invoked.
1662 ///
1663 /// * `argc` - The count of elements in the argv array.
1664 ///
1665 /// * `argv` - ArkTS values passed in as arguments to the function.
1666 ///
1667 /// * `result` - Whether the provided 'type_tag' is matched with the tag on the ArkTS object 'value'.
1668 ///
1669 ///
1670 /// # Returns
1671 ///
1672 /// * Returns the function execution status.
1673 /// [`napi_ok`] If the function executed successfully.
1674 ///
1675 /// [`napi_invalid_arg`] If the param env and(or) func is nullptr. If argv is nullptr but argc greater
1676 ///
1677 /// than 0.
1678 ///
1679 /// [`napi_function_expected`] If the param func is not an ArkTS Function.
1680 ///
1681 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1682 ///
1683 ///
1684 /// Available since API-level: 10
1685 pub fn napi_call_function(
1686 env: napi_env,
1687 recv: napi_value,
1688 func: napi_value,
1689 argc: usize,
1690 argv: *const napi_value,
1691 result: *mut napi_value,
1692 ) -> napi_status;
1693 /// Instantiate a new ArkTS value using a given napi_value that represents the constructor for the object.
1694 /// # Arguments
1695 ///
1696 /// * `env` - Current running virtual machine context.
1697 ///
1698 /// * `constructor` - The ArkTS function to be invoked as a constructor.
1699 ///
1700 /// * `argc` - The count of elements in the argv array.
1701 ///
1702 /// * `argv` - Array of ArkTS values representing the arguments to the constructor. If argc is 0 this parameter may
1703 /// be omitted by passing in nullptr.
1704 ///
1705 /// * `result` - The ArkTS object returned, which in this case is the constructed object.
1706 ///
1707 ///
1708 /// # Returns
1709 ///
1710 /// * Returns the function execution status.
1711 /// [`napi_ok`] If the function executed successfully.
1712 ///
1713 /// [`napi_invalid_arg`] If the param env and(or) func is nullptr. If argv is nullptr but argc greater
1714 ///
1715 /// than 0.
1716 ///
1717 /// [`napi_function_expected`] If the param func is not an ArkTS Function.
1718 ///
1719 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1720 ///
1721 ///
1722 /// Available since API-level: 10
1723 pub fn napi_new_instance(
1724 env: napi_env,
1725 constructor: napi_value,
1726 argc: usize,
1727 argv: *const napi_value,
1728 result: *mut napi_value,
1729 ) -> napi_status;
1730 /// Invoke instanceof operation on the object.
1731 /// # Arguments
1732 ///
1733 /// * `env` - Current running virtual machine context.
1734 ///
1735 /// * `object` - The ArkTS object to check.
1736 ///
1737 /// * `constructor` - The ArkTS constructor function to check against.
1738 ///
1739 /// * `result` - Set to true if the given ArkTS object instanceof constructor.
1740 ///
1741 ///
1742 /// # Returns
1743 ///
1744 /// * Returns the function execution status.
1745 /// [`napi_ok`] If the function executed successfully.
1746 ///
1747 /// [`napi_invalid_arg`] If the param env, object, constructor and(or) result is nullptr.
1748 ///
1749 /// [`napi_object_expected`] If the param object is not an ArkTS object value.
1750 ///
1751 /// [`napi_function_expected`] If the param constructor is not an ArkTS function value.
1752 ///
1753 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1754 ///
1755 ///
1756 /// Available since API-level: 10
1757 pub fn napi_instanceof(
1758 env: napi_env,
1759 object: napi_value,
1760 constructor: napi_value,
1761 result: *mut bool,
1762 ) -> napi_status;
1763 /// Obtains callback details about the call like arguments, this from given callback info.
1764 /// # Arguments
1765 ///
1766 /// * `env` - Current running virtual machine context.
1767 ///
1768 /// * `cbinfo` - The callback info.
1769 ///
1770 /// * `argc` - Size of the argv array.
1771 ///
1772 /// * `argv` - The Array which arguments will be copied to. If there are more arguments than the provided count, only
1773 /// the requested number of arguments are copied. If there are fewer arguments provided, the rest argv is
1774 /// filled with undefined. Can optionally be ignored by passing nullptr.
1775 ///
1776 /// * `this_arg` - Receives the ArkTS this argument for the call. Can optionally be ignored by passing nullptr.
1777 ///
1778 /// * `data` - Receives the data pointer for the callback. Can optionally be ignored by passing nullptr.
1779 ///
1780 ///
1781 /// # Returns
1782 ///
1783 /// * Returns the function execution status.
1784 /// [`napi_ok`] If the function executed successfully.
1785 ///
1786 /// [`napi_invalid_arg`] If the param env and(or) cbinfo is nullptr.
1787 ///
1788 ///
1789 /// Available since API-level: 10
1790 pub fn napi_get_cb_info(
1791 env: napi_env,
1792 cbinfo: napi_callback_info,
1793 argc: *mut usize,
1794 argv: *mut napi_value,
1795 this_arg: *mut napi_value,
1796 data: *mut *mut ::core::ffi::c_void,
1797 ) -> napi_status;
1798 /// Obtains callback details about the call like arguments, this from given callback info.
1799 /// # Arguments
1800 ///
1801 /// * `env` - Current running virtual machine context.
1802 ///
1803 /// * `cbinfo` - The callback info.
1804 ///
1805 /// * `result` - The new.target of the constructor call.
1806 ///
1807 ///
1808 /// # Returns
1809 ///
1810 /// * Returns the function execution status.
1811 /// [`napi_ok`] If the function executed successfully.
1812 ///
1813 /// [`napi_invalid_arg`] If the param env, cbinfo and(or) result is nullptr.
1814 ///
1815 ///
1816 /// Available since API-level: 10
1817 pub fn napi_get_new_target(
1818 env: napi_env,
1819 cbinfo: napi_callback_info,
1820 result: *mut napi_value,
1821 ) -> napi_status;
1822 /// Defines an ArkTS class, including constructor function and properties.
1823 /// # Arguments
1824 ///
1825 /// * `env` - Current running virtual machine context.
1826 ///
1827 /// * `utf8name` - Name of the ArkTS constructor function.
1828 ///
1829 /// * `length` - The length of the utf8name in bytes, or NAPI_AUTO_LENGTH if it is null-terminated.
1830 ///
1831 /// * `constructor` - Callback function that handles constructing instances of the class.
1832 ///
1833 /// * `data` - Optional data to be passed to the constructor callback as the data property of the callback info.
1834 ///
1835 /// * `property_count` - Number of items in the properties array argument.
1836 ///
1837 /// * `properties` - Array of property descriptors.
1838 ///
1839 /// * `result` - A napi_value representing the constructor function for the class.
1840 ///
1841 ///
1842 /// # Returns
1843 ///
1844 /// * Returns the function execution status.
1845 /// [`napi_ok`] If the function executed successfully.
1846 /// execution.
1847 ///
1848 /// [`napi_invalid_arg`] If the param env, utf8name and(or) result is nullptr. If napi_property_descriptor
1849 /// is nullptr but property_count greater than 0.
1850 ///
1851 /// [`napi_function_expected`] If the param func is not an ArkTS Function.
1852 ///
1853 /// [`napi_pending_exception`] If have uncaught exception, or exception occurs in execution.
1854 ///
1855 ///
1856 /// Available since API-level: 10
1857 pub fn napi_define_class(
1858 env: napi_env,
1859 utf8name: *const ::core::ffi::c_char,
1860 length: usize,
1861 constructor: napi_callback,
1862 data: *mut ::core::ffi::c_void,
1863 property_count: usize,
1864 properties: *const napi_property_descriptor,
1865 result: *mut napi_value,
1866 ) -> napi_status;
1867 /// Wraps a native instance in a ArkTS object. The native instance can be retrieved later using napi_unwrap.
1868 /// # Arguments
1869 ///
1870 /// * `env` - Current running virtual machine context.
1871 ///
1872 /// * `js_object` - The ArkTS object that will be the wrapper for the native object.
1873 ///
1874 /// * `native_object` - The native instance that will be wrapped in the ArkTS object.
1875 ///
1876 /// * `finalize_cb` - Native callback that can be used to free the native instance when the JavaScript object has
1877 /// been garbage-collected.
1878 ///
1879 /// * `finalize_hint` - Optional contextual hint that is passed to the finalize callback.
1880 ///
1881 /// * `result` - Optional reference to the wrapped object.
1882 ///
1883 ///
1884 /// # Returns
1885 ///
1886 /// * Returns the function execution status.
1887 /// [`napi_ok`] If the function executed successfully.
1888 ///
1889 /// [`napi_invalid_arg`] If the param env, js_object, native_object and(or) finalize_cb is nullptr.
1890 ///
1891 /// [`napi_object_expected`] If the param js_object is not an ArkTS Object.
1892 ///
1893 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1894 ///
1895 ///
1896 /// Available since API-level: 10
1897 pub fn napi_wrap(
1898 env: napi_env,
1899 js_object: napi_value,
1900 native_object: *mut ::core::ffi::c_void,
1901 finalize_cb: napi_finalize,
1902 finalize_hint: *mut ::core::ffi::c_void,
1903 result: *mut napi_ref,
1904 ) -> napi_status;
1905 /// Retrieves a native instance that was previously wrapped in an ArkTS object using napi_wrap.
1906 /// # Arguments
1907 ///
1908 /// * `env` - Current running virtual machine context.
1909 ///
1910 /// * `js_object` - The ArkTS object.
1911 ///
1912 /// * `result` - Pointer to the wrapped native instance.
1913 ///
1914 ///
1915 /// # Returns
1916 ///
1917 /// * Returns the function execution status.
1918 /// [`napi_ok`] If the function executed successfully.
1919 ///
1920 /// [`napi_invalid_arg`] If the param env, js_object and(or) result is nullptr.
1921 ///
1922 /// [`napi_object_expected`] If the param js_object is not an ArkTS Object.
1923 ///
1924 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1925 ///
1926 ///
1927 /// Available since API-level: 10
1928 pub fn napi_unwrap(
1929 env: napi_env,
1930 js_object: napi_value,
1931 result: *mut *mut ::core::ffi::c_void,
1932 ) -> napi_status;
1933 /// Retrieves a native instance that was previously wrapped in the ArkTS object js_object using napi_wrap
1934 /// and removes the wrapping.
1935 /// # Arguments
1936 ///
1937 /// * `env` - Current running virtual machine context.
1938 ///
1939 /// * `js_object` - The ArkTS object.
1940 ///
1941 /// * `result` - Pointer to the wrapped native instance.
1942 ///
1943 ///
1944 /// # Returns
1945 ///
1946 /// * Returns the function execution status.
1947 /// [`napi_ok`] If the function executed successfully.
1948 ///
1949 /// [`napi_invalid_arg`] If the param env, js_object and(or) result is nullptr.
1950 ///
1951 /// [`napi_object_expected`] If the param js_object is not an ArkTS Object.
1952 ///
1953 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1954 ///
1955 ///
1956 /// Available since API-level: 10
1957 pub fn napi_remove_wrap(
1958 env: napi_env,
1959 js_object: napi_value,
1960 result: *mut *mut ::core::ffi::c_void,
1961 ) -> napi_status;
1962 /// Allocates a JS value with external data.
1963 /// # Arguments
1964 ///
1965 /// * `env` - Current running virtual machine context.
1966 ///
1967 /// * `data` - Allocates a JS value that references external data.
1968 ///
1969 /// * `finalize_cb` - Optional callback to call when the external value is being collected.
1970 ///
1971 /// * `finalize_hint` - Optional hint that can be passed to the finalize callback function during the garbage
1972 /// collection process.
1973 ///
1974 /// * `result` - A napi_value representing an external value.
1975 ///
1976 ///
1977 /// # Returns
1978 ///
1979 /// * Returns the function execution status.
1980 /// [`napi_ok`] If the function executed successfully.
1981 ///
1982 /// [`napi_invalid_arg`] If the param env or result is nullptr.
1983 ///
1984 /// [`napi_pending_exception`] There is an uncaught exception occurred before(in) execution.
1985 ///
1986 ///
1987 /// Available since API-level: 10
1988 pub fn napi_create_external(
1989 env: napi_env,
1990 data: *mut ::core::ffi::c_void,
1991 finalize_cb: napi_finalize,
1992 finalize_hint: *mut ::core::ffi::c_void,
1993 result: *mut napi_value,
1994 ) -> napi_status;
1995 /// Obtains the external data pointer previously passed through napi_create_external().
1996 /// # Arguments
1997 ///
1998 /// * `env` - Current running virtual machine context.
1999 ///
2000 /// * `value` - JavaScript external value.
2001 ///
2002 /// * `result` - The data wrapped by the JavaScript external value.
2003 ///
2004 ///
2005 /// # Returns
2006 ///
2007 /// * Returns the function execution status.
2008 /// [`napi_ok`] If the function executed successfully.
2009 ///
2010 /// [`napi_invalid_arg`] If the param env, value or result is nullptr;
2011 ///
2012 /// [`napi_pending_exception`] There is an uncaught exception occurred before(in) execution.
2013 ///
2014 ///
2015 /// Available since API-level: 10
2016 pub fn napi_get_value_external(
2017 env: napi_env,
2018 value: napi_value,
2019 result: *mut *mut ::core::ffi::c_void,
2020 ) -> napi_status;
2021 /// Creates a reference for an object to extend its lifespan. The caller needs to manage the reference lifespan.
2022 /// # Arguments
2023 ///
2024 /// * `env` - Current running virtual machine context.
2025 ///
2026 /// * `value` - The napi_value that is being referenced.
2027 ///
2028 /// * `initial_refcount` - The initial count for the new reference.
2029 ///
2030 /// * `result` - napi_ref pointing to the new reference.
2031 ///
2032 ///
2033 /// # Returns
2034 ///
2035 /// * Returns the function execution status.
2036 /// [`napi_ok`] If the function executed successfully.
2037 ///
2038 /// [`napi_invalid_arg`] If env, value or result is nullptr.
2039 ///
2040 ///
2041 /// Available since API-level: 10
2042 pub fn napi_create_reference(
2043 env: napi_env,
2044 value: napi_value,
2045 initial_refcount: u32,
2046 result: *mut napi_ref,
2047 ) -> napi_status;
2048 /// Deletes the reference passed in.
2049 /// # Arguments
2050 ///
2051 /// * `env` - Current running virtual machine context.
2052 ///
2053 /// * `ref` - The napi_ref to be deleted.
2054 ///
2055 ///
2056 /// # Returns
2057 ///
2058 /// * Returns the function execution status.
2059 /// [`napi_ok`] If the function executed successfully.
2060 ///
2061 /// [`napi_invalid_arg`] If env or ref is nullptr.
2062 ///
2063 ///
2064 /// Available since API-level: 10
2065 pub fn napi_delete_reference(env: napi_env, ref_: napi_ref) -> napi_status;
2066 /// Increments the reference count for the reference passed in and returns the count.
2067 /// # Arguments
2068 ///
2069 /// * `env` - Current running virtual machine context.
2070 ///
2071 /// * `ref` - The napi_ref whose reference count will be incremented.
2072 ///
2073 /// * `result` - The new reference count.
2074 ///
2075 ///
2076 /// # Returns
2077 ///
2078 /// * Returns the function execution status.
2079 /// [`napi_ok`] If the function executed successfully.
2080 ///
2081 /// [`napi_invalid_arg`] If env or ref is nullptr.
2082 ///
2083 ///
2084 /// Available since API-level: 10
2085 pub fn napi_reference_ref(env: napi_env, ref_: napi_ref, result: *mut u32) -> napi_status;
2086 /// Decrements the reference count for the reference passed in and returns the count.
2087 /// # Arguments
2088 ///
2089 /// * `env` - Current running virtual machine context.
2090 ///
2091 /// * `ref` - The napi_ref whose reference count will be decremented.
2092 ///
2093 /// * `result` - The new reference count.
2094 ///
2095 ///
2096 /// # Returns
2097 ///
2098 /// * Returns the function execution status.
2099 /// [`napi_ok`] If the function executed successfully.
2100 ///
2101 /// [`napi_invalid_arg`] If env or ref is nullptr.
2102 ///
2103 ///
2104 /// Available since API-level: 10
2105 pub fn napi_reference_unref(env: napi_env, ref_: napi_ref, result: *mut u32) -> napi_status;
2106 /// Obtains the ArkTS Object associated with the reference.
2107 /// # Arguments
2108 ///
2109 /// * `env` - Current running virtual machine context.
2110 ///
2111 /// * `ref` - The napi_ref of the value being requested.
2112 ///
2113 /// * `result` - The napi_value referenced by the napi_ref.
2114 ///
2115 ///
2116 /// # Returns
2117 ///
2118 /// * Returns the function execution status.
2119 /// [`napi_ok`] If the function executed successfully.
2120 ///
2121 /// [`napi_invalid_arg`] If env, ref or result is nullptr.
2122 ///
2123 ///
2124 /// Available since API-level: 10
2125 pub fn napi_get_reference_value(
2126 env: napi_env,
2127 ref_: napi_ref,
2128 result: *mut napi_value,
2129 ) -> napi_status;
2130 /// Opens a scope.
2131 /// # Arguments
2132 ///
2133 /// * `env` - Current running virtual machine context.
2134 ///
2135 /// * `result` - napi_value representing the new scope.
2136 ///
2137 ///
2138 /// # Returns
2139 ///
2140 /// * Returns the function execution status.
2141 /// [`napi_ok`] If the function executed successfully.
2142 ///
2143 /// [`napi_invalid_arg`] If env or result is nullptr.
2144 ///
2145 ///
2146 /// Available since API-level: 10
2147 pub fn napi_open_handle_scope(env: napi_env, result: *mut napi_handle_scope) -> napi_status;
2148 /// Closes the scope passed in. After the scope is closed, all references declared in it are closed.
2149 /// # Arguments
2150 ///
2151 /// * `env` - Current running virtual machine context.
2152 ///
2153 /// * `scope` - The scope to close.
2154 ///
2155 ///
2156 /// # Returns
2157 ///
2158 /// * Returns the function execution status.
2159 /// [`napi_ok`] If the function executed successfully.
2160 ///
2161 /// [`napi_invalid_arg`] If env or scope is nullptr.
2162 ///
2163 /// [`napi_handle_scope_mismatch`] If there is no scope still existed.
2164 ///
2165 ///
2166 /// Available since API-level: 10
2167 pub fn napi_close_handle_scope(env: napi_env, scope: napi_handle_scope) -> napi_status;
2168 /// Opens an escapable handle scope from which the declared values can be returned to the outer scope.
2169 /// # Arguments
2170 ///
2171 /// * `env` - Current running virtual machine context.
2172 ///
2173 /// * `result` - The new scope.
2174 ///
2175 ///
2176 /// # Returns
2177 ///
2178 /// * Returns the function execution status.
2179 /// [`napi_ok`] If the function executed successfully.
2180 ///
2181 /// [`napi_invalid_arg`] If env or result is nullptr.
2182 ///
2183 ///
2184 /// Available since API-level: 10
2185 pub fn napi_open_escapable_handle_scope(
2186 env: napi_env,
2187 result: *mut napi_escapable_handle_scope,
2188 ) -> napi_status;
2189 /// Closes the escapable handle scope passed in.
2190 /// # Arguments
2191 ///
2192 /// * `env` - Current running virtual machine context.
2193 ///
2194 /// * `scope` - The scope to close.
2195 ///
2196 ///
2197 /// # Returns
2198 ///
2199 /// * Returns the function execution status.
2200 /// [`napi_ok`] If the function executed successfully.
2201 ///
2202 /// [`napi_invalid_arg`] If env or scope is nullptr.
2203 ///
2204 /// [`napi_handle_scope_mismatch`] If there is no scope still existed.
2205 ///
2206 ///
2207 /// Available since API-level: 10
2208 pub fn napi_close_escapable_handle_scope(
2209 env: napi_env,
2210 scope: napi_escapable_handle_scope,
2211 ) -> napi_status;
2212 /// Promotes the handle to the input ArkTS object so that it is valid for the lifespan of its outer scope.
2213 /// # Arguments
2214 ///
2215 /// * `env` - Current running virtual machine context.
2216 ///
2217 /// * `scope` - Current scope.
2218 ///
2219 /// * `escapee` - The ArkTS object to be escaped.
2220 ///
2221 /// * `result` - The handle to the escaped object in the outer scope.
2222 ///
2223 ///
2224 /// # Returns
2225 ///
2226 /// * Returns the function execution status.
2227 /// [`napi_ok`] If the function executed successfully.
2228 ///
2229 /// [`napi_invalid_arg`] If env, scope, escapee or result is nullptr.
2230 ///
2231 ///
2232 /// Available since API-level: 10
2233 pub fn napi_escape_handle(
2234 env: napi_env,
2235 scope: napi_escapable_handle_scope,
2236 escapee: napi_value,
2237 result: *mut napi_value,
2238 ) -> napi_status;
2239 /// Throws an ArkTS error.
2240 /// # Arguments
2241 ///
2242 /// * `env` - Current running virtual machine context.
2243 ///
2244 /// * `error` - The ArkTS error to be thrown.
2245 ///
2246 ///
2247 /// # Returns
2248 ///
2249 /// * Returns the function execution status.
2250 /// [`napi_ok`] If the function executed successfully.
2251 ///
2252 /// [`napi_invalid_arg`] If env or error is nullptr, or error is not an error object.
2253 ///
2254 ///
2255 /// Available since API-level: 10
2256 pub fn napi_throw(env: napi_env, error: napi_value) -> napi_status;
2257 /// Throws an ArkTS Error with text information.
2258 /// # Arguments
2259 ///
2260 /// * `env` - Current running virtual machine context.
2261 ///
2262 /// * `code` - Optional error code to set on the error.
2263 ///
2264 /// * `msg` - C string representing the text to be associated with the error.
2265 ///
2266 ///
2267 /// # Returns
2268 ///
2269 /// * Returns the function execution status.
2270 /// [`napi_ok`] If the function executed successfully.
2271 ///
2272 /// [`napi_invalid_arg`] If env or msg is nullptr.
2273 ///
2274 ///
2275 /// Available since API-level: 10
2276 pub fn napi_throw_error(
2277 env: napi_env,
2278 code: *const ::core::ffi::c_char,
2279 msg: *const ::core::ffi::c_char,
2280 ) -> napi_status;
2281 /// Throws an ArkTS TypeError with text information.
2282 /// # Arguments
2283 ///
2284 /// * `env` - Current running virtual machine context.
2285 ///
2286 /// * `code` - Optional error code to set on the error.
2287 ///
2288 /// * `msg` - C string representing the text to be associated with the error.
2289 ///
2290 ///
2291 /// # Returns
2292 ///
2293 /// * Returns the function execution status.
2294 /// [`napi_ok`] If the function executed successfully.
2295 ///
2296 /// [`napi_invalid_arg`] If env or msg is nullptr.
2297 ///
2298 ///
2299 /// Available since API-level: 10
2300 pub fn napi_throw_type_error(
2301 env: napi_env,
2302 code: *const ::core::ffi::c_char,
2303 msg: *const ::core::ffi::c_char,
2304 ) -> napi_status;
2305 /// Throws an ArkTS RangeError with text information.
2306 /// # Arguments
2307 ///
2308 /// * `env` - Current running virtual machine context.
2309 ///
2310 /// * `code` - Optional error code to set on the error.
2311 ///
2312 /// * `msg` - C string representing the text to be associated with the error.
2313 ///
2314 ///
2315 /// # Returns
2316 ///
2317 /// * Returns the function execution status.
2318 /// [`napi_ok`] If the function executed successfully.
2319 ///
2320 /// [`napi_invalid_arg`] If env or msg is nullptr.
2321 ///
2322 ///
2323 /// Available since API-level: 10
2324 pub fn napi_throw_range_error(
2325 env: napi_env,
2326 code: *const ::core::ffi::c_char,
2327 msg: *const ::core::ffi::c_char,
2328 ) -> napi_status;
2329 /// Checks whether a 'napi_value' is an error object.
2330 /// # Arguments
2331 ///
2332 /// * `env` - Current running virtual machine context.
2333 ///
2334 /// * `value` - The value to check
2335 ///
2336 /// * `result` - Boolean value that is set to true if the value represents an error object, false otherwise.
2337 ///
2338 ///
2339 /// # Returns
2340 ///
2341 /// * Returns the function execution status.
2342 /// [`napi_ok`] If the function executed successfully.
2343 ///
2344 /// [`napi_invalid_arg`] If env, value or result is nullptr.
2345 ///
2346 ///
2347 /// Available since API-level: 10
2348 pub fn napi_is_error(env: napi_env, value: napi_value, result: *mut bool) -> napi_status;
2349 /// Checks whether an exception occurs.
2350 /// # Arguments
2351 ///
2352 /// * `env` - Current running virtual machine context.
2353 ///
2354 /// * `result` - Boolean value that is true if there is a pending exception.
2355 ///
2356 ///
2357 /// # Returns
2358 ///
2359 /// * Returns the function execution status.
2360 /// [`napi_ok`] If the function executed successfully.
2361 ///
2362 /// [`napi_invalid_arg`] If env or result is nullptr.
2363 ///
2364 ///
2365 /// Available since API-level: 10
2366 pub fn napi_is_exception_pending(env: napi_env, result: *mut bool) -> napi_status;
2367 /// Obtains and clears the latest exception.
2368 /// # Arguments
2369 ///
2370 /// * `env` - Current running virtual machine context.
2371 ///
2372 /// * `result` - The exception if there is a pending exception; otherwise return a null value.
2373 ///
2374 ///
2375 /// # Returns
2376 ///
2377 /// * Returns the function execution status.
2378 /// [`napi_ok`] If the function executed successfully.
2379 ///
2380 /// [`napi_invalid_arg`] If env or result is nullptr.
2381 ///
2382 ///
2383 /// Available since API-level: 10
2384 pub fn napi_get_and_clear_last_exception(env: napi_env, result: *mut napi_value)
2385 -> napi_status;
2386 /// Checks if the ArkTS value is an ArkTS ArrayBuffer.
2387 /// # Arguments
2388 ///
2389 /// * `env` - Current running virtual machine context.
2390 ///
2391 /// * `value` - The ArkTS value to check.
2392 ///
2393 /// * `result` - Whether the given ArkTS value is an ArkTS ArrayBuffer.
2394 ///
2395 ///
2396 /// # Returns
2397 ///
2398 /// * Returns the function execution status.
2399 /// [`napi_ok`] If the function executed successfully.
2400 ///
2401 /// [`napi_invalid_arg`] If the param env, value and(or) result is nullptr.
2402 ///
2403 ///
2404 /// Available since API-level: 10
2405 pub fn napi_is_arraybuffer(env: napi_env, value: napi_value, result: *mut bool) -> napi_status;
2406 /// Creates an ArkTS ArrayBuffer of the specified size.
2407 /// # Arguments
2408 ///
2409 /// * `env` - Current running virtual machine context.
2410 ///
2411 /// * `byte_length` - The length in bytes of the array buffer.
2412 ///
2413 /// * `data` - The byte buffer of the ArrayBuffer.
2414 ///
2415 /// * `result` - A napi_value representing an ArkTS ArrayBuffer.
2416 ///
2417 ///
2418 /// # Returns
2419 ///
2420 /// * Returns the function execution status.
2421 /// [`napi_ok`] If the function executed successfully.
2422 ///
2423 /// [`napi_invalid_arg`] If the param env, data and(or) result is nullptr.
2424 ///
2425 /// [`napi_pending_exception`] There is an uncaught exception occurred before(in) execution.
2426 ///
2427 ///
2428 /// Available since API-level: 10
2429 pub fn napi_create_arraybuffer(
2430 env: napi_env,
2431 byte_length: usize,
2432 data: *mut *mut ::core::ffi::c_void,
2433 result: *mut napi_value,
2434 ) -> napi_status;
2435 /// The underlying data that ArrayBuffer point to.
2436 /// # Arguments
2437 ///
2438 /// * `env` - Current running virtual machine context.
2439 ///
2440 /// * `external_data` - Allocates an ArkTS value that references external data.
2441 ///
2442 /// * `byte_length` - The length in bytes of the underlying buffer.
2443 ///
2444 /// * `finalize_cb` - Optional callback to call when the ArrayBuffer is being collected.
2445 ///
2446 /// * `finalize_hint` - Optional hint that can be passed to the finalize callback function during the garbage
2447 /// collection process.
2448 ///
2449 /// * `result` - A napi_value representing an ArkTS ArrayBuffer.
2450 ///
2451 ///
2452 /// # Returns
2453 ///
2454 /// * Returns the function execution status.
2455 /// [`napi_ok`] If the function executed successfully.
2456 ///
2457 /// [`napi_invalid_arg`] If the param env, external_data, finalize_cb and(or) result is nullptr.
2458 ///
2459 /// [`napi_pending_exception`] There is an uncaught exception occurred before(in) execution.
2460 ///
2461 ///
2462 /// Available since API-level: 10
2463 pub fn napi_create_external_arraybuffer(
2464 env: napi_env,
2465 external_data: *mut ::core::ffi::c_void,
2466 byte_length: usize,
2467 finalize_cb: napi_finalize,
2468 finalize_hint: *mut ::core::ffi::c_void,
2469 result: *mut napi_value,
2470 ) -> napi_status;
2471 /// Obtains the underlying data buffer of ArrayBuffer and its length.
2472 /// # Arguments
2473 ///
2474 /// * `env` - Current running virtual machine context.
2475 ///
2476 /// * `arraybuffer` - The napi_value representing the ArrayBuffer being queried.
2477 ///
2478 /// * `data` - The underlying data buffer of the ArrayBuffer.
2479 ///
2480 /// * `byte_length` - Length in bytes of the underlying data buffer.
2481 ///
2482 ///
2483 /// # Returns
2484 ///
2485 /// * Returns the function execution status.
2486 /// [`napi_ok`] If the function executed successfully.
2487 ///
2488 /// [`napi_invalid_arg`] If the param env, arraybuffer and(or) byte_length is nullptr.
2489 ///
2490 /// [`napi_arraybuffer_expected`] If the param is neither ArkTS TypedArray nor SendableArrayBuffer.
2491 ///
2492 /// [`napi_pending_exception`] There is an uncaught exception occurred before(in) execution.
2493 ///
2494 ///
2495 /// Available since API-level: 10
2496 pub fn napi_get_arraybuffer_info(
2497 env: napi_env,
2498 arraybuffer: napi_value,
2499 data: *mut *mut ::core::ffi::c_void,
2500 byte_length: *mut usize,
2501 ) -> napi_status;
2502 /// Checks if the ArkTS value is an ArkTS TypedArray.
2503 /// # Arguments
2504 ///
2505 /// * `env` - Current running virtual machine context.
2506 ///
2507 /// * `value` - The ArkTS value to check.
2508 ///
2509 /// * `result` - Whether the given ArkTS value is an ArkTS TypedArray.
2510 ///
2511 ///
2512 /// # Returns
2513 ///
2514 /// * Returns the function execution status.
2515 /// [`napi_ok`] If the function executed successfully.
2516 ///
2517 /// [`napi_invalid_arg`] If the param env, value and(or) result is nullptr.
2518 ///
2519 ///
2520 /// Available since API-level: 10
2521 pub fn napi_is_typedarray(env: napi_env, value: napi_value, result: *mut bool) -> napi_status;
2522 /// Creates an ArkTS TypeArray from an existing ArrayBuffer.
2523 /// # Arguments
2524 ///
2525 /// * `env` - Current running virtual machine context.
2526 ///
2527 /// * `type` - The element datatype of the TypedArray.
2528 ///
2529 /// * `length` - Number of elements in the TypedArray.
2530 ///
2531 /// * `arraybuffer` - The underlying ArrayBuffer that supports the TypedArray.
2532 ///
2533 /// * `byte_offset` - The byte offset within the ArrayBuffer from which to start projecting the TypedArray.
2534 ///
2535 /// * `result` - A napi_value representing an ArkTS TypedArray.
2536 ///
2537 ///
2538 /// # Returns
2539 ///
2540 /// * Returns the function execution status.
2541 /// [`napi_ok`] If the function executed successfully.
2542 ///
2543 /// [`napi_invalid_arg`] If the param env, arraybuffer and(or) result is nullptr;
2544 ///
2545 /// If param type is not a valid napi_typedarray_type.
2546 ///
2547 /// [`napi_arraybuffer_expected`] If a non-arraybuffer ArkTS value passed in it.
2548 ///
2549 /// [`napi_pending_exception`] There is an uncaught exception occurred before(in) execution.
2550 ///
2551 ///
2552 /// Available since API-level: 10
2553 pub fn napi_create_typedarray(
2554 env: napi_env,
2555 type_: napi_typedarray_type,
2556 length: usize,
2557 arraybuffer: napi_value,
2558 byte_offset: usize,
2559 result: *mut napi_value,
2560 ) -> napi_status;
2561 /// Obtains properties of a TypedArray.
2562 /// # Arguments
2563 ///
2564 /// * `env` - Current running virtual machine context.
2565 ///
2566 /// * `typedarray` - The napi_value for the TypedArray whose properties are being checked.
2567 ///
2568 /// * `type` - The datatype of elements in the TypedArray.
2569 ///
2570 /// * `length` - The number of elements in the TypedArray.
2571 ///
2572 /// * `data` - The data buffer underlying the TypedArray adjusted by the byte_offset.
2573 ///
2574 /// * `arraybuffer` - The ArrayBuffer underlying the TypedArray.
2575 ///
2576 /// * `byte_offset` - The byte offset within the underlying arraybuffer
2577 ///
2578 ///
2579 /// # Returns
2580 ///
2581 /// * Returns the function execution status.
2582 /// [`napi_ok`] If the function executed successfully.
2583 ///
2584 /// [`napi_invalid_arg`] If the param env and(or) typedarray is nullptr;
2585 ///
2586 /// If the param typedarray is neither ArkTS TypedArray nor SendableTypedArray.
2587 ///
2588 ///
2589 /// Available since API-level: 10
2590 pub fn napi_get_typedarray_info(
2591 env: napi_env,
2592 typedarray: napi_value,
2593 type_: *mut napi_typedarray_type,
2594 length: *mut usize,
2595 data: *mut *mut ::core::ffi::c_void,
2596 arraybuffer: *mut napi_value,
2597 byte_offset: *mut usize,
2598 ) -> napi_status;
2599 /// Creates an ArkTS DataView from an existing ArrayBuffer.
2600 /// # Arguments
2601 ///
2602 /// * `env` - Current running virtual machine context.
2603 ///
2604 /// * `length` - Number of elements in the DataView.
2605 ///
2606 /// * `arraybuffer` - The underlying ArrayBuffer that supports the DataView.
2607 ///
2608 /// * `byte_offset` - The byte offset within the ArrayBuffer from which to start projecting the DataView.
2609 ///
2610 /// * `result` - A napi_value representing an ArkTS DataView.
2611 ///
2612 ///
2613 /// # Returns
2614 ///
2615 /// * Returns the function execution status.
2616 /// [`napi_ok`] If the function executed successfully.
2617 ///
2618 /// [`napi_invalid_arg`] If the param env, arraybuffer and(or) result is nullptr.
2619 ///
2620 /// [`napi_arraybuffer_expected`] If a non-arraybuffer ArkTS value passed in it.
2621 ///
2622 /// [`napi_pending_exception`] There is an uncaught exception occurred before(in) execution.
2623 ///
2624 /// If the sum of byte_length and length is greater than the byte length of
2625 ///
2626 /// the arraybuffer.
2627 ///
2628 ///
2629 /// Available since API-level: 10
2630 pub fn napi_create_dataview(
2631 env: napi_env,
2632 length: usize,
2633 arraybuffer: napi_value,
2634 byte_offset: usize,
2635 result: *mut napi_value,
2636 ) -> napi_status;
2637 /// Checks if the ArkTS value is an ArkTS DataView.
2638 /// # Arguments
2639 ///
2640 /// * `env` - Current running virtual machine context.
2641 ///
2642 /// * `value` - The ArkTS value to check.
2643 ///
2644 /// * `result` - Whether the given ArkTS value is an ArkTS DataView.
2645 ///
2646 ///
2647 /// # Returns
2648 ///
2649 /// * Returns the function execution status.
2650 /// [`napi_ok`] If the function executed successfully.
2651 ///
2652 /// [`napi_invalid_arg`] If the param env, value and(or) result is nullptr.
2653 ///
2654 ///
2655 /// Available since API-level: 10
2656 pub fn napi_is_dataview(env: napi_env, value: napi_value, result: *mut bool) -> napi_status;
2657 /// Obtains properties of a DataView.
2658 /// # Arguments
2659 ///
2660 /// * `env` - Current running virtual machine context.
2661 ///
2662 /// * `dataview` - The napi_value for the DataView whose properties are being checked.
2663 ///
2664 /// * `bytelength` - The number of elements in the DataView.
2665 ///
2666 /// * `data` - The data buffer underlying the DataView.
2667 ///
2668 /// * `arraybuffer` - The ArrayBuffer underlying the DataView.
2669 ///
2670 /// * `byte_offset` - The byte offset within the underlying arraybuffer
2671 ///
2672 ///
2673 /// # Returns
2674 ///
2675 /// * Returns the function execution status.
2676 /// [`napi_ok`] If the function executed successfully.
2677 ///
2678 /// [`napi_invalid_arg`] If the param env and(or) dataview is nullptr;
2679 ///
2680 /// If non-dataview ArkTS value passed in.
2681 ///
2682 ///
2683 /// Available since API-level: 10
2684 pub fn napi_get_dataview_info(
2685 env: napi_env,
2686 dataview: napi_value,
2687 bytelength: *mut usize,
2688 data: *mut *mut ::core::ffi::c_void,
2689 arraybuffer: *mut napi_value,
2690 byte_offset: *mut usize,
2691 ) -> napi_status;
2692 pub fn napi_get_version(env: napi_env, result: *mut u32) -> napi_status;
2693 /// Creates a deferred object and an ArkTS promise.
2694 /// # Arguments
2695 ///
2696 /// * `env` - Current running virtual machine context.
2697 ///
2698 /// * `deferred` - The created deferred object which will be passed to 'napi_resolve_deferred()' or
2699 /// 'napi_reject_deferred()' to resolve or reject the promise.
2700 ///
2701 /// * `promise` - The ArkTS promise which is associated with the deferred object.
2702 ///
2703 /// # Returns
2704 ///
2705 /// * Returns the function execution status.
2706 /// [`napi_ok`] If the function executed successfully.
2707 ///
2708 /// [`napi_invalid_arg`] If env, deferred or resolution is nullptr.
2709 ///
2710 /// [`napi_pending_exception`] If an ArkTS exception existed when the function was called.
2711 ///
2712 /// [`napi_generic_failure`] If create promise failed.
2713 ///
2714 ///
2715 /// Available since API-level: 10
2716 pub fn napi_create_promise(
2717 env: napi_env,
2718 deferred: *mut napi_deferred,
2719 promise: *mut napi_value,
2720 ) -> napi_status;
2721 /// Resolves a promise by way of the deferred object associated.
2722 /// # Arguments
2723 ///
2724 /// * `env` - Current running virtual machine context.
2725 ///
2726 /// * `deferred` - The deferred object which is utilized to resolve the promise.
2727 ///
2728 /// * `resolution` - The resolution value used to resolve the promise.
2729 ///
2730 /// # Returns
2731 ///
2732 /// * Returns the function execution status.
2733 /// [`napi_ok`] If the function executed successfully.
2734 ///
2735 /// [`napi_invalid_arg`] If env, deferred or resolution is nullptr.
2736 ///
2737 /// [`napi_pending_exception`] If an ArkTS exception existed when the function was called.
2738 ///
2739 ///
2740 /// Available since API-level: 10
2741 pub fn napi_resolve_deferred(
2742 env: napi_env,
2743 deferred: napi_deferred,
2744 resolution: napi_value,
2745 ) -> napi_status;
2746 /// Rejects a promise by way of the deferred object associated.
2747 /// # Arguments
2748 ///
2749 /// * `env` - Current running virtual machine context.
2750 ///
2751 /// * `deferred` - The deferred object which is utilized to reject the promise.
2752 ///
2753 /// * `rejection` - The rejection value used to reject the promise.
2754 ///
2755 /// # Returns
2756 ///
2757 /// * Returns the function execution status.
2758 /// [`napi_ok`] If the function executed successfully.
2759 ///
2760 /// [`napi_invalid_arg`] If env, deferred or rejection is nullptr.
2761 ///
2762 /// [`napi_pending_exception`] If an ArkTS exception existed when the function was called.
2763 ///
2764 ///
2765 /// Available since API-level: 10
2766 pub fn napi_reject_deferred(
2767 env: napi_env,
2768 deferred: napi_deferred,
2769 rejection: napi_value,
2770 ) -> napi_status;
2771 /// Checks whether the given 'napi_value' is a promise object.
2772 /// # Arguments
2773 ///
2774 /// * `env` - Current running virtual machine context.
2775 ///
2776 /// * `value` - The 'napi_value' to be checked.
2777 ///
2778 /// * `is_promise` - Boolean value that is set to true if the 'value' is a promise object, false otherwise.
2779 ///
2780 /// # Returns
2781 ///
2782 /// * Returns the function execution status.
2783 /// [`napi_ok`] If the function executed successfully.
2784 ///
2785 /// [`napi_invalid_arg`] If env, value or is_promise is nullptr.
2786 ///
2787 ///
2788 /// Available since API-level: 10
2789 pub fn napi_is_promise(env: napi_env, value: napi_value, is_promise: *mut bool) -> napi_status;
2790 pub fn napi_run_script(
2791 env: napi_env,
2792 script: napi_value,
2793 result: *mut napi_value,
2794 ) -> napi_status;
2795 pub fn napi_adjust_external_memory(
2796 env: napi_env,
2797 change_in_bytes: i64,
2798 adjusted_value: *mut i64,
2799 ) -> napi_status;
2800 /// Creates an ArkTS 'Date' object from C double data
2801 /// # Arguments
2802 ///
2803 /// * `env` - Current running virtual machine context.
2804 ///
2805 /// * `time` - ArkTS time value in milliseconds format since 01 January, 1970 UTC.
2806 ///
2807 /// * `result` - Created ArkTS data object.
2808 ///
2809 /// # Returns
2810 ///
2811 /// * Returns the function execution status.
2812 /// [`napi_ok`] If the function executed successfully.
2813 ///
2814 /// [`napi_invalid_arg`] If env or result is nullptr.
2815 ///
2816 /// [`napi_pending_exception`] If an ArkTS exception existed when the function was called.
2817 ///
2818 ///
2819 /// Available since API-level: 10
2820 pub fn napi_create_date(env: napi_env, time: f64, result: *mut napi_value) -> napi_status;
2821 /// Checks whether the given ArkTS value is a 'Date' object. You can use this API to check the type
2822 /// of the parameter passed from ArkTS.
2823 /// # Arguments
2824 ///
2825 /// * `env` - Current running virtual machine context.
2826 ///
2827 /// * `value` - ArkTS data object.
2828 ///
2829 /// * `is_date` - Boolean value that is set to true if the 'value' is a 'Date' object, false otherwise.
2830 ///
2831 /// # Returns
2832 ///
2833 /// * Returns the function execution status.
2834 /// [`napi_ok`] If the function executed successfully.
2835 ///
2836 /// [`napi_invalid_arg`] If env, value or is_date is nullptr.
2837 ///
2838 ///
2839 /// Available since API-level: 10
2840 pub fn napi_is_date(env: napi_env, value: napi_value, is_date: *mut bool) -> napi_status;
2841 /// Obtains the C equivalent of the given ArkTS 'Date' object.
2842 ///
2843 /// # Arguments
2844 ///
2845 /// * `env` - Current running virtual machine context.
2846 ///
2847 /// * `value` - ArkTS data object.
2848 ///
2849 /// * `result` - C time value in milliseconds format since 01 January, 1970 UTC.
2850 ///
2851 /// # Returns
2852 ///
2853 /// * Returns the function execution status.
2854 /// [`napi_ok`] If the function executed successfully.
2855 ///
2856 /// [`napi_invalid_arg`] If env, value or result is nullptr.
2857 ///
2858 /// [`napi_pending_exception`] If an ArkTS exception existed when the function was called.
2859 ///
2860 /// [`napi_date_expected`] If the 'value' is not a 'Date' object.
2861 ///
2862 ///
2863 /// Available since API-level: 10
2864 pub fn napi_get_date_value(env: napi_env, value: napi_value, result: *mut f64) -> napi_status;
2865 /// Adds a 'napi_finalize' callback, which will be called when the ArkTS object is garbage-collected.
2866 ///
2867 /// # Arguments
2868 ///
2869 /// * `env` - Current running virtual machine context.
2870 ///
2871 /// * `js_object` - The ArkTS object value.
2872 ///
2873 /// * `native_object` - Native object to bind with the ArkTS object.
2874 ///
2875 /// * `finalize_cb` - Native callback that can be used to free the native object
2876 /// when the ArkTS object is garbage-collected.
2877 ///
2878 /// * `finalize_hint` - Optional contextual hint that is passed to the finalize callback.
2879 ///
2880 /// * `result` - Optional reference of the ArkTS object.
2881 ///
2882 ///
2883 /// # Returns
2884 ///
2885 /// * Return the function execution status.
2886 ///
2887 /// Available since API-level: 11
2888 #[cfg(feature = "api-11")]
2889 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
2890 pub fn napi_add_finalizer(
2891 env: napi_env,
2892 js_object: napi_value,
2893 native_object: *mut ::core::ffi::c_void,
2894 finalize_cb: napi_finalize,
2895 finalize_hint: *mut ::core::ffi::c_void,
2896 result: *mut napi_ref,
2897 ) -> napi_status;
2898 /// Creates an ArkTS BigInt from C int64 data.
2899 ///
2900 /// # Arguments
2901 ///
2902 /// * `env` - Current running virtual machine context.
2903 ///
2904 /// * `value` - C int64 data.
2905 ///
2906 /// * `result` - Created ArkTS BigInt object from C int64 data.
2907 ///
2908 /// # Returns
2909 ///
2910 /// * Returns the function execution status.
2911 /// [`napi_ok`] If the function executed successfully.
2912 ///
2913 /// [`napi_invalid_arg`] If env or result is nullptr.
2914 ///
2915 ///
2916 /// Available since API-level: 10
2917 pub fn napi_create_bigint_int64(
2918 env: napi_env,
2919 value: i64,
2920 result: *mut napi_value,
2921 ) -> napi_status;
2922 /// Creates an ArkTS BigInt from C int64 data.
2923 ///
2924 /// # Arguments
2925 ///
2926 /// * `env` - Current running virtual machine context.
2927 ///
2928 /// * `value` - C int64 data.
2929 ///
2930 /// * `result` - Created ArkTS BigInt object from C int64 data.
2931 ///
2932 /// # Returns
2933 ///
2934 /// * Returns the function execution status.
2935 /// [`napi_ok`] If the function executed successfully.
2936 ///
2937 /// [`napi_invalid_arg`] If env or result is nullptr.
2938 ///
2939 ///
2940 /// Available since API-level: 10
2941 pub fn napi_create_bigint_uint64(
2942 env: napi_env,
2943 value: u64,
2944 result: *mut napi_value,
2945 ) -> napi_status;
2946 /// Creates a single ArkTS BigInt from a C uint64 array.
2947 ///
2948 /// # Arguments
2949 ///
2950 /// * `env` - Current running virtual machine context.
2951 ///
2952 /// * `sign_bit` - Sign bit of the BigInt. If sign_bit is 0, the BigInt is positive, otherwise it is negative.
2953 ///
2954 /// * `word_count` - The size of the words array.
2955 ///
2956 /// * `words` - C uint64 array in little-endian 64-bit format.
2957 ///
2958 /// * `result` - Created ArkTS BigInt object from C int64 array.
2959 ///
2960 /// # Returns
2961 ///
2962 /// * Returns the function execution status.
2963 /// [`napi_ok`] If the function executed successfully.
2964 ///
2965 /// [`napi_invalid_arg`] If env, words or result is nullptr or word_count is larger than 2147483647.
2966 ///
2967 /// [`napi_pending_exception`] If an ArkTS exception existed when the function was called.
2968 ///
2969 ///
2970 /// Available since API-level: 10
2971 pub fn napi_create_bigint_words(
2972 env: napi_env,
2973 sign_bit: ::core::ffi::c_int,
2974 word_count: usize,
2975 words: *const u64,
2976 result: *mut napi_value,
2977 ) -> napi_status;
2978 /// Obtains a signed 64-bit integer from an ArkTS BigInt object.
2979 ///
2980 /// # Arguments
2981 ///
2982 /// * `env` - Current running virtual machine context.
2983 ///
2984 /// * `value` - ArkTS BigInt object.
2985 ///
2986 /// * `result` - Pointer points to the location where store the C signed 64-bit integer value.
2987 ///
2988 /// * `lossless` - Indicates whether the conversion is lossless. If lossless is true, the conversion is lossless,
2989 /// false otherwise.
2990 ///
2991 /// # Returns
2992 ///
2993 /// * Returns the function execution status.
2994 /// [`napi_ok`] If the function executed successfully.
2995 ///
2996 /// [`napi_invalid_arg`] If env, value, result or lossless is nullptr or word_count is larger than
2997 ///
2998 /// 2147483647.
2999 ///
3000 /// [`napi_bigint_expected`] If the 'value' is not an ArkTS bigint object.
3001 ///
3002 ///
3003 /// Available since API-level: 10
3004 pub fn napi_get_value_bigint_int64(
3005 env: napi_env,
3006 value: napi_value,
3007 result: *mut i64,
3008 lossless: *mut bool,
3009 ) -> napi_status;
3010 /// Obtains an unsigned 64-bit integer from an ArkTS BigInt object.
3011 ///
3012 /// # Arguments
3013 ///
3014 /// * `env` - Current running virtual machine context.
3015 ///
3016 /// * `value` - ArkTS BigInt object.
3017 ///
3018 /// * `result` - Pointer points to the location where store the C unsigned 64-bit integer value.
3019 ///
3020 /// * `lossless` - Indicates whether the conversion is lossless. If lossless is true, the conversion is lossless,
3021 /// false otherwise.
3022 ///
3023 /// # Returns
3024 ///
3025 /// * Returns the function execution status.
3026 /// [`napi_ok`] If the function executed successfully.
3027 ///
3028 /// [`napi_invalid_arg`] If env, value, result or lossless is nullptr or word_count is larger than
3029 ///
3030 /// 2147483647.
3031 ///
3032 /// [`napi_bigint_expected`] If the 'value' is not an ArkTS bigint object.
3033 ///
3034 ///
3035 /// Available since API-level: 10
3036 pub fn napi_get_value_bigint_uint64(
3037 env: napi_env,
3038 value: napi_value,
3039 result: *mut u64,
3040 lossless: *mut bool,
3041 ) -> napi_status;
3042 /// Obtains the underlying 64-bit unsigned (uint64) byte data from an ArkTS BigInt object.
3043 ///
3044 /// # Arguments
3045 ///
3046 /// * `env` - Current running virtual machine context.
3047 ///
3048 /// * `value` - ArkTS BigInt object.
3049 ///
3050 /// * `sign_bit` - Sign bit of the BigInt. If sign_bit is 0, the BigInt is positive, otherwise it is negative.
3051 ///
3052 /// * `word_count` - The size of the words array.
3053 ///
3054 /// * `words` - C uint64 array in little-endian 64-bit format.
3055 ///
3056 /// # Returns
3057 ///
3058 /// * Returns the function execution status.
3059 /// [`napi_ok`] If the function executed successfully.
3060 ///
3061 /// [`napi_invalid_arg`] If env, value or word_count is nullptr or word_count is larger than 2147483647.
3062 ///
3063 /// [`napi_bigint_expected`] If the 'value' is not an ArkTS bigint object.
3064 ///
3065 ///
3066 /// Available since API-level: 10
3067 pub fn napi_get_value_bigint_words(
3068 env: napi_env,
3069 value: napi_value,
3070 sign_bit: *mut ::core::ffi::c_int,
3071 word_count: *mut usize,
3072 words: *mut u64,
3073 ) -> napi_status;
3074 /// Obtains the names of all properties of an ArkTS object.
3075 ///
3076 /// # Arguments
3077 ///
3078 /// * `env` - Current running virtual machine context.
3079 ///
3080 /// * `object` - ArkTS object.
3081 ///
3082 /// * `key_mode` - Key collection mode. If key_mode is napi_key_include_prototypes, the result includes properties on
3083 /// prototypes. If key_mode is napi_key_own_only, the result includes only properties directly on own
3084 /// object.
3085 ///
3086 /// * `key_filter` - Which properties to be collected.
3087 ///
3088 /// * `key_conversion` - Key conversion mode. If key_conversion is napi_key_keep_numbers, the numbered property keys
3089 /// will keep number type. If key_conversion is napi_key_numbers_to_strings, the numbered property
3090 /// keys will be convert to string type.
3091 ///
3092 /// * `result` - An array of ArkTS object that represent the property names of the object.
3093 ///
3094 /// # Returns
3095 ///
3096 /// * Returns the function execution status.
3097 /// [`napi_ok`] If the function executed successfully.
3098 ///
3099 /// [`napi_invalid_arg`] If env, object or result is nullptr;
3100 ///
3101 /// key_mode is not enumeration value of napi_key_collection_mode;
3102 ///
3103 /// key_conversion is not enumeration value of napi_key_conversion.
3104 ///
3105 /// [`napi_pending_exception`] If an ArkTS exception existed when the function was called.
3106 ///
3107 /// [`napi_object_expected`] If object is not object type and function type.
3108 ///
3109 ///
3110 /// Available since API-level: 10
3111 pub fn napi_get_all_property_names(
3112 env: napi_env,
3113 object: napi_value,
3114 key_mode: napi_key_collection_mode,
3115 key_filter: napi_key_filter,
3116 key_conversion: napi_key_conversion,
3117 result: *mut napi_value,
3118 ) -> napi_status;
3119 /// Associates data with the currently running environment.
3120 ///
3121 /// # Arguments
3122 ///
3123 /// * `env` - Current running virtual machine context.
3124 ///
3125 /// * `data` - Data item to bind with the 'env'.
3126 ///
3127 /// * `finalize_cb` - Optional native callback that will be triggered when 'env' is destroyed or this interface
3128 /// repeatedly calls.
3129 ///
3130 /// * `finalize_hint` - Optional contextual hint that is passed to the finalize callback.
3131 ///
3132 ///
3133 /// # Returns
3134 ///
3135 /// * Returns the function execution status.
3136 ///
3137 /// Available since API-level: 11
3138 #[cfg(feature = "api-11")]
3139 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
3140 pub fn napi_set_instance_data(
3141 env: napi_env,
3142 data: *mut ::core::ffi::c_void,
3143 finalize_cb: napi_finalize,
3144 finalize_hint: *mut ::core::ffi::c_void,
3145 ) -> napi_status;
3146 /// Retrieves the data that was previously associated with the currently running environment.
3147 ///
3148 /// # Arguments
3149 ///
3150 /// * `env` - Current running virtual machine context.
3151 ///
3152 /// * `data` - Data item is bound with the 'env'.
3153 ///
3154 ///
3155 /// # Returns
3156 ///
3157 /// * Returns the function execution status.
3158 ///
3159 /// Available since API-level: 11
3160 #[cfg(feature = "api-11")]
3161 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
3162 pub fn napi_get_instance_data(
3163 env: napi_env,
3164 data: *mut *mut ::core::ffi::c_void,
3165 ) -> napi_status;
3166 /// Detaches the underlying data from an 'ArrayBuffer' object. After the data is detached, you
3167 /// can operate the data in C/C++.
3168 ///
3169 /// # Arguments
3170 ///
3171 /// * `env` - Current running virtual machine context.
3172 ///
3173 /// * `arraybuffer` - ArkTS ArrayBuffer object.
3174 ///
3175 /// # Returns
3176 ///
3177 /// * Returns the function execution status.
3178 /// [`napi_ok`] If the function executed successfully.
3179 ///
3180 /// [`napi_invalid_arg`] If env or arraybuffer is nullptr, if 'arraybuffer' is not an ArrayBuffer object.
3181 ///
3182 /// [`napi_object_expected`] If the 'arraybuffer' is not an ArkTS object.
3183 ///
3184 ///
3185 /// Available since API-level: 10
3186 pub fn napi_detach_arraybuffer(env: napi_env, arraybuffer: napi_value) -> napi_status;
3187 /// Checks whether the given 'ArrayBuffer' has been detached.
3188 ///
3189 /// # Arguments
3190 ///
3191 /// * `env` - Current running virtual machine context.
3192 ///
3193 /// * `value` - ArkTS ArrayBuffer object.
3194 ///
3195 /// * `result` - Boolean value that is set to true if the 'value' has been detached, false otherwise.
3196 ///
3197 /// # Returns
3198 ///
3199 /// * Returns the function execution status.
3200 /// [`napi_ok`] If the function executed successfully.
3201 ///
3202 /// [`napi_invalid_arg`] If env, value or result is nullptr.
3203 ///
3204 ///
3205 /// Available since API-level: 10
3206 pub fn napi_is_detached_arraybuffer(
3207 env: napi_env,
3208 value: napi_value,
3209 result: *mut bool,
3210 ) -> napi_status;
3211 pub fn napi_type_tag_object(
3212 env: napi_env,
3213 value: napi_value,
3214 type_tag: *const napi_type_tag,
3215 ) -> napi_status;
3216 pub fn napi_check_object_type_tag(
3217 env: napi_env,
3218 value: napi_value,
3219 type_tag: *const napi_type_tag,
3220 result: *mut bool,
3221 ) -> napi_status;
3222 /// Freezes an ArkTS object. Once an object is frozen, its properties are immutable.
3223 ///
3224 /// # Arguments
3225 ///
3226 /// * `env` - Current running virtual machine context.
3227 ///
3228 /// * `object` - The given ArkTS object.
3229 ///
3230 /// # Returns
3231 ///
3232 /// * Returns the function execution status.
3233 /// [`napi_ok`] If the function executed successfully.
3234 ///
3235 /// [`napi_invalid_arg`] If env or object is nullptr.
3236 ///
3237 /// [`napi_pending_exception`] If an ArkTS exception existed when the function was called.
3238 ///
3239 ///
3240 /// Available since API-level: 10
3241 pub fn napi_object_freeze(env: napi_env, object: napi_value) -> napi_status;
3242 /// Seals an ArkTS object. Once an object is sealed, its properties cannot be added or deleted, but property
3243 /// values can be modified.
3244 ///
3245 /// # Arguments
3246 ///
3247 /// * `env` - Current running virtual machine context.
3248 ///
3249 /// * `object` - The given ArkTS object.
3250 ///
3251 /// # Returns
3252 ///
3253 /// * Returns the function execution status.
3254 /// [`napi_ok`] If the function executed successfully.
3255 ///
3256 /// [`napi_invalid_arg`] If env or object is nullptr.
3257 ///
3258 /// [`napi_pending_exception`] If an ArkTS exception existed when the function was called.
3259 ///
3260 ///
3261 /// Available since API-level: 10
3262 pub fn napi_object_seal(env: napi_env, object: napi_value) -> napi_status;
3263 /// Registers a native module.
3264 ///
3265 /// # Arguments
3266 ///
3267 /// * `mod` - Native module of type 'napi_module' to be registered.
3268 ///
3269 /// Available since API-level: 10
3270 pub fn napi_module_register(mod_: *mut napi_module);
3271 /// Raises a fatal error to terminate the process immediately.
3272 /// # Arguments
3273 ///
3274 /// * `location` - Optional location for the error occurrence.
3275 ///
3276 /// * `location_len` - The byte length of the location, or NAPI_AUTO_LENGTH if it is terminated by a null character.
3277 ///
3278 /// * `message` - The message associated with the error.
3279 ///
3280 /// * `message_len` - The byte length of the message, or NAPI_AUTO_LENGTH if it is terminated by a null character.
3281 ///
3282 ///
3283 /// Available since API-level: 10
3284 pub fn napi_fatal_error(
3285 location: *const ::core::ffi::c_char,
3286 location_len: usize,
3287 message: *const ::core::ffi::c_char,
3288 message_len: usize,
3289 ) -> !;
3290 /// Creates an asynchronous context. The capabilities related to 'async_hook' are not supported currently.
3291 ///
3292 /// # Arguments
3293 ///
3294 /// * `env` - Current running virtual machine context.
3295 ///
3296 /// * `async_resource` - Object associated with the async work that will be passed to possible 'async_hook'.
3297 ///
3298 /// * `async_resource_name` - Identifier for the kind of resource that is being provided for diagnostic information
3299 /// exposed by the async_hooks API.
3300 ///
3301 /// * `result` - The initialized async context.
3302 ///
3303 ///
3304 /// # Returns
3305 ///
3306 /// * Returns the function execution status.
3307 ///
3308 /// Available since API-level: 11
3309 #[cfg(feature = "api-11")]
3310 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
3311 pub fn napi_async_init(
3312 env: napi_env,
3313 async_resource: napi_value,
3314 async_resource_name: napi_value,
3315 result: *mut napi_async_context,
3316 ) -> napi_status;
3317 /// Destroys the previously created asynchronous context. The capabilities related to 'async_hook' are not
3318 /// supported currently.
3319 ///
3320 /// # Arguments
3321 ///
3322 /// * `env` - Current running virtual machine context.
3323 ///
3324 /// * `async_context` - The async context to be destroyed.
3325 ///
3326 ///
3327 /// # Returns
3328 ///
3329 /// * Returns the function execution status.
3330 ///
3331 /// Available since API-level: 11
3332 #[cfg(feature = "api-11")]
3333 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
3334 pub fn napi_async_destroy(env: napi_env, async_context: napi_async_context) -> napi_status;
3335 /// Allows an ArkTS function to be called in the asynchronous context. The capabilities related to 'async_hook'
3336 /// are not supported currently.
3337 /// # Arguments
3338 ///
3339 /// * `env` - Current running virtual machine context.
3340 ///
3341 /// * `async_context` - The context environment for the async operation.
3342 ///
3343 /// * `recv` - The 'this' pointer of the function.
3344 ///
3345 /// * `func` - ArkTS function to be called.
3346 ///
3347 /// * `argc` - Size of the argument array which is passed to 'func'.
3348 ///
3349 /// * `argv` - Argument array.
3350 ///
3351 /// * `result` - Result returned by the ArkTS function.
3352 ///
3353 ///
3354 /// # Returns
3355 ///
3356 /// * Returns the function execution status.
3357 /// [`napi_ok`] If the function executed successfully.
3358 ///
3359 /// [`napi_invalid_arg`] If the param env, func and(or) recv is nullptr;
3360 ///
3361 /// If the param argc is greater than 0 but argv is nullptr.
3362 ///
3363 /// [`napi_object_expected`] If the param recv is not an ArkTS Object.
3364 ///
3365 /// [`napi_function_expected`] If the param func is not an ArkTS Function.
3366 ///
3367 /// [`napi_pending_exception`] There is an uncaught exception occurred before(in) execution.
3368 ///
3369 ///
3370 /// Available since API-level: 11
3371 #[cfg(feature = "api-11")]
3372 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
3373 pub fn napi_make_callback(
3374 env: napi_env,
3375 async_context: napi_async_context,
3376 recv: napi_value,
3377 func: napi_value,
3378 argc: usize,
3379 argv: *const napi_value,
3380 result: *mut napi_value,
3381 ) -> napi_status;
3382 /// Creates an ArkTS ArrayBuffer object of the specified size.
3383 ///
3384 /// # Arguments
3385 ///
3386 /// * `env` - Current running virtual machine context.
3387 ///
3388 /// * `length` - Bytes size of the underlying arraybuffer.
3389 ///
3390 /// * `data` - Raw pointer to the underlying arraybuffer.
3391 ///
3392 /// * `result` - Created ArkTS ArrayBuffer object.
3393 ///
3394 /// # Returns
3395 ///
3396 /// * Returns the function execution status.
3397 /// [`napi_ok`] If the function executed successfully.
3398 ///
3399 /// [`napi_invalid_arg`] If env, data or result is nullptr, or length is larger than 2097152,
3400 /// or length is less than zero.
3401 ///
3402 ///
3403 /// Available since API-level: 10
3404 pub fn napi_create_buffer(
3405 env: napi_env,
3406 length: usize,
3407 data: *mut *mut ::core::ffi::c_void,
3408 result: *mut napi_value,
3409 ) -> napi_status;
3410 /// Creates an ArkTS ArrayBuffer object of the specified size and initializes it with the given data.
3411 ///
3412 /// # Arguments
3413 ///
3414 /// * `env` - Current running virtual machine context.n
3415 ///
3416 /// * `length` - Bytes size of the given data.
3417 ///
3418 /// * `data` - Given data.
3419 ///
3420 /// * `finalize_cb` - Optional native callback that can be used to free the given data when the ArkTS ArrayBuffer
3421 /// object has been garbage-collected.
3422 ///
3423 /// * `finalize_hint` - Optional contextual hint that is passed to the finalize callback.
3424 ///
3425 /// * `result` - Created ArkTS ArrayBuffer object.
3426 ///
3427 /// # Returns
3428 ///
3429 /// * Returns the function execution status.
3430 /// [`napi_ok`] If the function executed successfully.
3431 ///
3432 /// [`napi_invalid_arg`] If env, data or result is nullptr, or length is larger than 2097152,
3433 /// or length is less than or equal to zero.
3434 ///
3435 /// [`napi_pending_exception`] If an ArkTS exception existed when the function was called.
3436 ///
3437 ///
3438 /// Available since API-level: 10
3439 pub fn napi_create_external_buffer(
3440 env: napi_env,
3441 length: usize,
3442 data: *mut ::core::ffi::c_void,
3443 finalize_cb: napi_finalize,
3444 finalize_hint: *mut ::core::ffi::c_void,
3445 result: *mut napi_value,
3446 ) -> napi_status;
3447 /// Creates an ArkTS ArrayBuffer object of the specified size and initializes it with the given data.
3448 ///
3449 /// # Arguments
3450 ///
3451 /// * `env` - Current running virtual machine context.
3452 ///
3453 /// * `length` - Bytes size of the given data.
3454 ///
3455 /// * `data` - Given data.
3456 ///
3457 /// * `result_data` - Raw pointer to the underlying arraybuffer.
3458 ///
3459 /// * `result` - Created ArkTS ArrayBuffer object.
3460 ///
3461 /// # Returns
3462 ///
3463 /// * Returns the function execution status.
3464 /// [`napi_ok`] If the function executed successfully.
3465 ///
3466 /// [`napi_invalid_arg`] If env, data or result is nullptr, or length is larger than 2097152,
3467 /// or length is less than or equal to zero.
3468 ///
3469 ///
3470 /// Available since API-level: 10
3471 pub fn napi_create_buffer_copy(
3472 env: napi_env,
3473 length: usize,
3474 data: *const ::core::ffi::c_void,
3475 result_data: *mut *mut ::core::ffi::c_void,
3476 result: *mut napi_value,
3477 ) -> napi_status;
3478 /// Checks whether the given ArkTS value is a 'ArrayBuffer' object.
3479 ///
3480 /// # Arguments
3481 ///
3482 /// * `env` - Current running virtual machine context.
3483 ///
3484 /// * `value` - ArkTS ArrayBuffer object.
3485 ///
3486 /// * `result` - Boolean value that is set to true if the 'value' is a 'ArrayBuffer' object, false otherwise.
3487 ///
3488 /// # Returns
3489 ///
3490 /// * Returns the function execution status.
3491 /// [`napi_ok`] If the function executed successfully.
3492 ///
3493 /// [`napi_invalid_arg`] If env, value or result is nullptr.
3494 ///
3495 ///
3496 /// Available since API-level: 10
3497 pub fn napi_is_buffer(env: napi_env, value: napi_value, result: *mut bool) -> napi_status;
3498 /// Obtains the underlying data of 'ArrayBuffer' and its length.
3499 ///
3500 /// # Arguments
3501 ///
3502 /// * `env` - Current running virtual machine context.
3503 ///
3504 /// * `value` - ArkTS ArrayBuffer object.
3505 ///
3506 /// * `data` - Raw pointer to the underlying arraybuffer.
3507 ///
3508 /// * `length` - Bytes size of the underlying arraybuffer.
3509 ///
3510 /// # Returns
3511 ///
3512 /// * Returns the function execution status.
3513 /// [`napi_ok`] If the function executed successfully.
3514 ///
3515 /// [`napi_invalid_arg`] If env, value or result is nullptr.
3516 ///
3517 /// [`napi_arraybuffer_expected`] If the 'value' is not an ArkTS array buffer object.
3518 ///
3519 ///
3520 /// Available since API-level: 10
3521 pub fn napi_get_buffer_info(
3522 env: napi_env,
3523 value: napi_value,
3524 data: *mut *mut ::core::ffi::c_void,
3525 length: *mut usize,
3526 ) -> napi_status;
3527 /// Allocate a work object that is used to execute logic asynchronously.
3528 /// # Arguments
3529 ///
3530 /// * `env` - Current running virtual machine context.
3531 ///
3532 /// * `async_resource` - Not supported, can be ignored by passing nullptr.
3533 ///
3534 /// * `async_resource_name` - Identifier for the kind of resource that is being provided for diagnostic information
3535 /// exposed by the HiTrace.
3536 ///
3537 /// * `execute` - The native function which should be called to execute the logic asynchronously. The given function
3538 /// is called from a worker pool thread and can execute in parallel with the main event loop thread.
3539 ///
3540 /// * `complete` - The native function which will be called when the asynchronous logic is completed or is cancelled.
3541 /// The given function is called from the main event loop thread.
3542 ///
3543 /// * `data` - User-provided data context. This will be passed back into the execute and complete functions.
3544 ///
3545 /// * `result` - The handle to the newly created async work.
3546 ///
3547 ///
3548 /// # Returns
3549 ///
3550 /// * Returns the function execution status.
3551 /// [`napi_ok`] If the function executed successfully.
3552 ///
3553 /// [`napi_invalid_arg`] If the param env, async_resource_name, execute, complete and(or) result is
3554 ///
3555 /// nullptr.
3556 ///
3557 ///
3558 /// Available since API-level: 10
3559 pub fn napi_create_async_work(
3560 env: napi_env,
3561 async_resource: napi_value,
3562 async_resource_name: napi_value,
3563 execute: napi_async_execute_callback,
3564 complete: napi_async_complete_callback,
3565 data: *mut ::core::ffi::c_void,
3566 result: *mut napi_async_work,
3567 ) -> napi_status;
3568 /// Free a previously allocated work object.
3569 /// # Arguments
3570 ///
3571 /// * `env` - Current running virtual machine context.
3572 ///
3573 /// * `work` - The handle returned by the call to napi_create_async_work.
3574 ///
3575 ///
3576 /// # Returns
3577 ///
3578 /// * Returns the function execution status.
3579 /// [`napi_ok`] If the function executed successfully.
3580 ///
3581 /// [`napi_invalid_arg`] If the param env and(or) work is nullptr.
3582 ///
3583 ///
3584 /// Available since API-level: 10
3585 pub fn napi_delete_async_work(env: napi_env, work: napi_async_work) -> napi_status;
3586 /// Requests that the previously allocated work be scheduled for execution. Once it returns successfully,
3587 /// this API must not be called again with the same napi_async_work item or the result will be undefined.
3588 /// # Arguments
3589 ///
3590 /// * `env` - Current running virtual machine context.
3591 ///
3592 /// * `work` - The handle returned by the call to napi_create_async_work.
3593 ///
3594 ///
3595 /// # Returns
3596 ///
3597 /// * Returns the function execution status.
3598 /// [`napi_ok`] If the function executed successfully.
3599 ///
3600 /// [`napi_invalid_arg`] If the param env and(or) work is nullptr.
3601 ///
3602 ///
3603 /// Available since API-level: 10
3604 pub fn napi_queue_async_work(env: napi_env, work: napi_async_work) -> napi_status;
3605 /// Cancels queued work if it has not yet been started. If it has already started executing, it cannot be
3606 /// cancelled. If successful, the complete callback will be invoked with a status value of napi_cancelled.
3607 /// The work should not be deleted before the complete callback invocation, even if it has been successfully
3608 /// cancelled.
3609 /// # Arguments
3610 ///
3611 /// * `env` - Current running virtual machine context.
3612 ///
3613 /// * `work` - The handle returned by the call to napi_create_async_work.
3614 ///
3615 ///
3616 /// # Returns
3617 ///
3618 /// * Returns the function execution status.
3619 /// [`napi_ok`] If the function executed successfully.
3620 ///
3621 /// [`napi_invalid_arg`] If the param env and(or) work is nullptr.
3622 ///
3623 ///
3624 /// Available since API-level: 10
3625 pub fn napi_cancel_async_work(env: napi_env, work: napi_async_work) -> napi_status;
3626 pub fn napi_get_node_version(
3627 env: napi_env,
3628 version: *mut *const napi_node_version,
3629 ) -> napi_status;
3630 /// Obtains the current libuv loop instance.
3631 /// # Arguments
3632 ///
3633 /// * `env` - Current running virtual machine context.
3634 ///
3635 /// * `loop` - Libuv event loop.
3636 ///
3637 /// # Returns
3638 ///
3639 /// * Returns the function execution status.
3640 /// [`napi_ok`] If the function executed successfully.
3641 ///
3642 /// [`napi_invalid_arg`] If env or loop is nullptr.
3643 ///
3644 /// [`napi_generic_failure`] If env is invalid.
3645 ///
3646 ///
3647 /// Available since API-level: 10
3648 pub fn napi_get_uv_event_loop(env: napi_env, loop_: *mut *mut uv_loop_s) -> napi_status;
3649 /// Throws UncaughtException to ArkTS.
3650 /// # Arguments
3651 ///
3652 /// * `env` - Current running virtual machine context.
3653 ///
3654 /// * `err` - Error object which is passed to 'UncaughtException'.
3655 ///
3656 ///
3657 /// # Returns
3658 ///
3659 /// * Returns the function execution status.
3660 /// [`napi_ok`] If the function executed successfully.
3661 ///
3662 /// [`napi_invalid_arg`] If the param env and(or) err is nullptr;
3663 ///
3664 /// If the param err is not an ArkTS Error value.
3665 ///
3666 /// [`napi_pending_exception`] There is an uncaught exception occurred before execution.
3667 ///
3668 ///
3669 /// Available since API-level: 12
3670 #[cfg(feature = "api-12")]
3671 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
3672 pub fn napi_fatal_exception(env: napi_env, err: napi_value) -> napi_status;
3673 /// Registers a clean-up hook for releasing resources when the environment exits.
3674 ///
3675 /// # Arguments
3676 ///
3677 /// * `env` - Current running virtual machine context.
3678 ///
3679 /// * `fun` - Function pointer which will be triggered when environment is destroy.
3680 ///
3681 /// * `arg` - The argument is passed to the function pointer 'fun'.
3682 ///
3683 ///
3684 /// # Returns
3685 ///
3686 /// * Returns the function execution status.
3687 ///
3688 /// Available since API-level: 11
3689 #[cfg(feature = "api-11")]
3690 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
3691 pub fn napi_add_env_cleanup_hook(
3692 env: napi_env,
3693 fun: ::core::option::Option<unsafe extern "C" fn(arg: *mut ::core::ffi::c_void)>,
3694 arg: *mut ::core::ffi::c_void,
3695 ) -> napi_status;
3696 /// Unregisters the clean-up hook.
3697 ///
3698 /// # Arguments
3699 ///
3700 /// * `env` - Current running virtual machine context.
3701 ///
3702 /// * `fun` - Function pointer which will be triggered when environment is destroy.
3703 ///
3704 /// * `arg` - The argument is passed to the function pointer 'fun'.
3705 ///
3706 ///
3707 /// # Returns
3708 ///
3709 /// * Returns the function execution status.
3710 ///
3711 /// Available since API-level: 11
3712 #[cfg(feature = "api-11")]
3713 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
3714 pub fn napi_remove_env_cleanup_hook(
3715 env: napi_env,
3716 fun: ::core::option::Option<unsafe extern "C" fn(arg: *mut ::core::ffi::c_void)>,
3717 arg: *mut ::core::ffi::c_void,
3718 ) -> napi_status;
3719 /// Opens a callback scope. The capabilities related to 'async_hook' are not supported currently.
3720 /// # Arguments
3721 ///
3722 /// * `env` - Current running virtual machine context.
3723 ///
3724 /// * `resource_object` - The resource object to be passed to possible 'async_hook'.
3725 ///
3726 /// * `context` - The context environment for the async operation.
3727 ///
3728 /// * `result` - The generated callback scope.
3729 ///
3730 ///
3731 /// # Returns
3732 ///
3733 /// * Returns the function execution status.
3734 ///
3735 /// Available since API-level: 11
3736 #[cfg(feature = "api-11")]
3737 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
3738 pub fn napi_open_callback_scope(
3739 env: napi_env,
3740 resource_object: napi_value,
3741 context: napi_async_context,
3742 result: *mut napi_callback_scope,
3743 ) -> napi_status;
3744 /// Closes the callback scope. The capabilities related to 'async_hook' are not supported currently.
3745 ///
3746 /// # Arguments
3747 ///
3748 /// * `env` - Current running virtual machine context.
3749 ///
3750 /// * `scope` - The callback scope to be closed.
3751 ///
3752 ///
3753 /// # Returns
3754 ///
3755 /// * Returns the function execution status.
3756 ///
3757 /// Available since API-level: 11
3758 #[cfg(feature = "api-11")]
3759 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
3760 pub fn napi_close_callback_scope(env: napi_env, scope: napi_callback_scope) -> napi_status;
3761 /// Creates a thread-safe function.
3762 /// # Arguments
3763 ///
3764 /// * `env` - Current running virtual machine context.
3765 ///
3766 /// * `func` - ArkTS function to be called.
3767 ///
3768 /// * `async_resource` - An optional Object associated with the async work that will be passed to possible
3769 /// 'async_hooks'.
3770 ///
3771 /// * `async_resource_name` - An ArkTS string to provide an identifier for the kind of resource that is being
3772 /// provided for diagnostic information exposed by the `async_hooks` interface.
3773 ///
3774 /// * `max_queue_size` - Maximum size of the event queue in the thread-safe function.
3775 ///
3776 /// * `initial_thread_count` - Initial thread count of the thread-safe function.
3777 ///
3778 /// * `thread_finalize_data` - Data passed to the finalize callback.
3779 ///
3780 /// * `thread_finalize_cb` - Finalize callback function which will be triggered when the thread-safe function is
3781 /// released.
3782 ///
3783 /// * `context` - Optional data is passed to 'call_js_cb'.
3784 ///
3785 /// * `call_js_cb` - Callback function which will be triggered after 'napi_call_threadsafe_function()' is called.
3786 ///
3787 /// * `result` - The created thread-safe function.
3788 ///
3789 /// # Returns
3790 ///
3791 /// * Returns the function execution status.
3792 /// [`napi_ok`] If the function executed successfully.
3793 ///
3794 /// [`napi_invalid_arg`] If env, async_resource_name or result is nullptr; max_queue_size is less than 0;
3795 ///
3796 /// initial_thread_count is greater than 128 or less than 0; func and call_js_cb are
3797 ///
3798 /// nullptr at same time.
3799 ///
3800 /// [`napi_generic_failure`] If create thread-safe function failed.
3801 ///
3802 ///
3803 /// Available since API-level: 10
3804 pub fn napi_create_threadsafe_function(
3805 env: napi_env,
3806 func: napi_value,
3807 async_resource: napi_value,
3808 async_resource_name: napi_value,
3809 max_queue_size: usize,
3810 initial_thread_count: usize,
3811 thread_finalize_data: *mut ::core::ffi::c_void,
3812 thread_finalize_cb: napi_finalize,
3813 context: *mut ::core::ffi::c_void,
3814 call_js_cb: napi_threadsafe_function_call_js,
3815 result: *mut napi_threadsafe_function,
3816 ) -> napi_status;
3817 /// Obtains the context of a thread-safe function.
3818 /// # Arguments
3819 ///
3820 /// * `func` - The created thread-safe function.
3821 ///
3822 /// * `result` - Pointer pointer to the context of the thread-safe function.
3823 ///
3824 /// # Returns
3825 ///
3826 /// * Returns the function execution status.
3827 /// [`napi_ok`] If the function executed successfully.
3828 ///
3829 /// [`napi_invalid_arg`] If func or result is nullptr.
3830 ///
3831 ///
3832 /// Available since API-level: 10
3833 pub fn napi_get_threadsafe_function_context(
3834 func: napi_threadsafe_function,
3835 result: *mut *mut ::core::ffi::c_void,
3836 ) -> napi_status;
3837 /// Calls a thread-safe function.
3838 /// # Arguments
3839 ///
3840 /// * `func` - The created thread-safe function.
3841 ///
3842 /// * `data` - Data passed to the callback function 'call_js_cb' which is registered by calling
3843 /// 'napi_create_threadsafe_function()'.
3844 ///
3845 /// * `is_blocking` - If true, this function blocks until the event queue is not full. If false, return directly.
3846 ///
3847 /// # Returns
3848 ///
3849 /// * Returns the function execution status.
3850 /// [`napi_ok`] If the function executed successfully.
3851 ///
3852 /// [`napi_invalid_arg`] If func is nullptr.
3853 ///
3854 /// [`napi_queue_full`] If event queue is full.
3855 ///
3856 /// [`napi_closing`] If the thread-safe function is closing.
3857 ///
3858 /// [`napi_generic_failure`] If call thread-safe function failed.
3859 ///
3860 ///
3861 /// Available since API-level: 10
3862 pub fn napi_call_threadsafe_function(
3863 func: napi_threadsafe_function,
3864 data: *mut ::core::ffi::c_void,
3865 is_blocking: napi_threadsafe_function_call_mode,
3866 ) -> napi_status;
3867 /// Acquires a thread-safe function.
3868 /// # Arguments
3869 ///
3870 /// * `func` - The created thread-safe function.
3871 ///
3872 /// # Returns
3873 ///
3874 /// * Returns the function execution status.
3875 /// [`napi_ok`] If the function executed successfully.
3876 ///
3877 /// [`napi_invalid_arg`] If func is nullptr.
3878 ///
3879 /// [`napi_generic_failure`] If acquire thread-safe function failed.
3880 ///
3881 ///
3882 /// Available since API-level: 10
3883 pub fn napi_acquire_threadsafe_function(func: napi_threadsafe_function) -> napi_status;
3884 /// Releases a thread-safe function.
3885 /// # Arguments
3886 ///
3887 /// * `func` - The created thread-safe function.
3888 ///
3889 /// * `mode` - Value of mode can be either 'napi_tsfn_release' to indicate that no more calls should be made
3890 /// to the thread-safe function from current thread or 'napi_tsfn_abort' to indicate that the queue
3891 /// of the thread-safe function will be closed and 'napi_closing' will be return when calling
3892 /// 'napi_call_threadsafe_function()' under the circumstance.
3893 ///
3894 /// # Returns
3895 ///
3896 /// * Returns the function execution status.
3897 /// [`napi_ok`] If the function executed successfully.
3898 ///
3899 /// [`napi_invalid_arg`] If func is nullptr.
3900 ///
3901 /// [`napi_generic_failure`] If release thread-safe function failed.
3902 ///
3903 ///
3904 /// Available since API-level: 10
3905 pub fn napi_release_threadsafe_function(
3906 func: napi_threadsafe_function,
3907 mode: napi_threadsafe_function_release_mode,
3908 ) -> napi_status;
3909 /// Indicates that the event loop running on the main thread may exit before the thread-safe function
3910 /// is destroyed.
3911 /// # Arguments
3912 ///
3913 /// * `env` - Current running virtual machine context.
3914 ///
3915 /// * `func` - The created thread-safe function.
3916 ///
3917 /// # Returns
3918 ///
3919 /// * Returns the function execution status.
3920 /// [`napi_ok`] If the function executed successfully.
3921 ///
3922 /// [`napi_invalid_arg`] If env or func is nullptr.
3923 ///
3924 /// [`napi_generic_failure`] If unref thread-safe function failed.
3925 ///
3926 ///
3927 /// Available since API-level: 10
3928 pub fn napi_unref_threadsafe_function(
3929 env: napi_env,
3930 func: napi_threadsafe_function,
3931 ) -> napi_status;
3932 /// Indicates that the event loop running on the main thread should not exit until the thread-safe
3933 /// function is destroyed.
3934 /// # Arguments
3935 ///
3936 /// * `env` - Current running virtual machine context.
3937 ///
3938 /// * `func` - The created thread-safe function.
3939 ///
3940 /// # Returns
3941 ///
3942 /// * Returns the function execution status.
3943 /// [`napi_ok`] If the function executed successfully.
3944 ///
3945 /// [`napi_invalid_arg`] If env or func is nullptr.
3946 ///
3947 /// [`napi_generic_failure`] If ref thread-safe function failed.
3948 ///
3949 ///
3950 /// Available since API-level: 10
3951 pub fn napi_ref_threadsafe_function(
3952 env: napi_env,
3953 func: napi_threadsafe_function,
3954 ) -> napi_status;
3955 /// Registers an asynchronous clean-up hook for releasing resources when the environment exits.
3956 ///
3957 /// # Arguments
3958 ///
3959 /// * `env` - Current running virtual machine context.
3960 ///
3961 /// * `hook` - The function pointer to call at environment teardown.
3962 ///
3963 /// * `arg` - The pointer to pass to `hook` when it gets called.
3964 ///
3965 /// * `remove_handle` - Optional handle that refers to the asynchronous cleanup.
3966 ///
3967 ///
3968 /// # Returns
3969 ///
3970 /// * Returns the function execution status.
3971 ///
3972 /// Available since API-level: 11
3973 #[cfg(feature = "api-11")]
3974 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
3975 pub fn napi_add_async_cleanup_hook(
3976 env: napi_env,
3977 hook: napi_async_cleanup_hook,
3978 arg: *mut ::core::ffi::c_void,
3979 remove_handle: *mut napi_async_cleanup_hook_handle,
3980 ) -> napi_status;
3981 /// Unregisters the asynchronous clean-up hook.
3982 ///
3983 /// # Arguments
3984 ///
3985 /// * `remove_handle` - Optional handle that refers to the asynchronous cleanup.
3986 ///
3987 ///
3988 /// # Returns
3989 ///
3990 /// * Returns the function execution status.
3991 ///
3992 /// Available since API-level: 11
3993 #[cfg(feature = "api-11")]
3994 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
3995 pub fn napi_remove_async_cleanup_hook(
3996 remove_handle: napi_async_cleanup_hook_handle,
3997 ) -> napi_status;
3998 /// Obtains the absolute path of the location, from which the addon is loaded.
3999 ///
4000 /// # Arguments
4001 ///
4002 /// * `env` - Current running virtual machine context.
4003 ///
4004 /// * `result` - The absolute path of the location of the loaded addon.
4005 ///
4006 ///
4007 /// # Returns
4008 ///
4009 /// * Returns the function execution status.
4010 ///
4011 /// Available since API-level: 11
4012 #[cfg(feature = "api-11")]
4013 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
4014 pub fn node_api_get_module_file_name(
4015 env: napi_env,
4016 result: *mut *const ::core::ffi::c_char,
4017 ) -> napi_status;
4018 pub fn napi_run_script_path(
4019 env: napi_env,
4020 path: *const ::core::ffi::c_char,
4021 result: *mut napi_value,
4022 ) -> napi_status;
4023 pub fn napi_queue_async_work_with_qos(
4024 env: napi_env,
4025 work: napi_async_work,
4026 qos: napi_qos_t,
4027 ) -> napi_status;
4028 /// Loads an .abc file as a module. This API returns the namespace of the module.
4029 /// # Arguments
4030 ///
4031 /// * `env` - Current running virtual machine context.
4032 ///
4033 /// * `path` - Path of the .abc file or name of the module to load.
4034 ///
4035 /// * `result` - Result of the module object.
4036 ///
4037 ///
4038 /// # Returns
4039 ///
4040 /// * Returns the function execution status.
4041 ///
4042 /// Available since API-level: 11
4043 #[cfg(feature = "api-11")]
4044 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
4045 pub fn napi_load_module(
4046 env: napi_env,
4047 path: *const ::core::ffi::c_char,
4048 result: *mut napi_value,
4049 ) -> napi_status;
4050 /// Create ArkTS Object with initial properties given by descriptors, note that property key must be String, and
4051 /// must can not convert to element_index, also all keys must not duplicate.
4052 ///
4053 /// # Arguments
4054 ///
4055 /// * `env` - Current running virtual machine context.
4056 ///
4057 /// * `result` - The created ArkTS object.
4058 ///
4059 /// * `property_count` - Number of the property descriptors.
4060 ///
4061 /// * `properties` - Array of property descriptors which are expected to be applied to the ArkTS object.
4062 ///
4063 ///
4064 /// # Returns
4065 ///
4066 /// * Returns the function execution status.
4067 ///
4068 /// Available since API-level: 11
4069 #[cfg(feature = "api-11")]
4070 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
4071 pub fn napi_create_object_with_properties(
4072 env: napi_env,
4073 result: *mut napi_value,
4074 property_count: usize,
4075 properties: *const napi_property_descriptor,
4076 ) -> napi_status;
4077 /// Create ArkTS Object with initial properties given by keys and values, note that property key must be String,
4078 /// and must can not convert to element_index, also all keys must not duplicate.
4079 ///
4080 /// # Arguments
4081 ///
4082 /// * `env` - Current running virtual machine context.
4083 ///
4084 /// * `result` - The absolute path of the location of the loaded addon.
4085 ///
4086 /// * `property_count` - Number of the propertied which needs to be applied on the ArkTS object.
4087 ///
4088 /// * `keys` - Array of the keys of the properties.
4089 ///
4090 /// * `values` - Array of the values of the properties.
4091 ///
4092 ///
4093 /// # Returns
4094 ///
4095 /// * Returns the function execution status.
4096 ///
4097 /// Available since API-level: 11
4098 #[cfg(feature = "api-11")]
4099 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
4100 pub fn napi_create_object_with_named_properties(
4101 env: napi_env,
4102 result: *mut napi_value,
4103 property_count: usize,
4104 keys: *mut *const ::core::ffi::c_char,
4105 values: *const napi_value,
4106 ) -> napi_status;
4107 /// This API sets native properties to a object and converts this ArkTS object to native binding object.
4108 ///
4109 /// # Arguments
4110 ///
4111 /// * `env` - Current running virtual machine context.
4112 ///
4113 /// * `js_object` - The ArkTS value to coerce.
4114 ///
4115 /// * `detach_cb` - Native callback that can be used to detach the ArkTS object and the native object.
4116 ///
4117 /// * `attach_cb` - Native callback that can be used to bind the ArkTS object and the native object.
4118 ///
4119 /// * `native_object` - User-provided native instance to pass to thr detach callback and attach callback.
4120 ///
4121 /// * `hint` - Optional hint to pass to the detach callback and attach callback.
4122 ///
4123 ///
4124 /// # Returns
4125 ///
4126 /// * Return the function execution status.
4127 ///
4128 /// Available since API-level: 11
4129 #[cfg(feature = "api-11")]
4130 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
4131 pub fn napi_coerce_to_native_binding_object(
4132 env: napi_env,
4133 js_object: napi_value,
4134 detach_cb: napi_native_binding_detach_callback,
4135 attach_cb: napi_native_binding_attach_callback,
4136 native_object: *mut ::core::ffi::c_void,
4137 hint: *mut ::core::ffi::c_void,
4138 ) -> napi_status;
4139 /// The module is loaded through the NAPI. By default, the default object is exported from the module.
4140 ///
4141 /// # Arguments
4142 ///
4143 /// * `env` - Current running virtual machine context.
4144 ///
4145 /// * `path` - Path name of the module to be loaded, like
4146 /// * `module_info` - Path names of bundle and module, like com.example.application/entry.
4147 ///
4148 /// * `result` - Result of loading a module, which is an exported object of the module.
4149 ///
4150 ///
4151 /// # Returns
4152 ///
4153 /// * Returns the function execution status.
4154 ///
4155 /// Available since API-level: 12
4156 #[cfg(feature = "api-12")]
4157 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4158 pub fn napi_load_module_with_info(
4159 env: napi_env,
4160 path: *const ::core::ffi::c_char,
4161 module_info: *const ::core::ffi::c_char,
4162 result: *mut napi_value,
4163 ) -> napi_status;
4164 /// Create the ark runtime.
4165 ///
4166 /// # Arguments
4167 ///
4168 /// * `env` - Indicates the ark runtime environment.
4169 ///
4170 ///
4171 /// # Returns
4172 ///
4173 /// * Return the function execution status.
4174 ///
4175 /// Available since API-level: 12
4176 #[cfg(feature = "api-12")]
4177 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4178 pub fn napi_create_ark_runtime(env: *mut napi_env) -> napi_status;
4179 /// Destroy the ark runtime.
4180 ///
4181 /// # Arguments
4182 ///
4183 /// * `env` - Indicates the ark runtime environment.
4184 ///
4185 ///
4186 /// # Returns
4187 ///
4188 /// * Return the function execution status.
4189 ///
4190 /// Available since API-level: 12
4191 #[cfg(feature = "api-12")]
4192 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4193 pub fn napi_destroy_ark_runtime(env: *mut napi_env) -> napi_status;
4194 /// Defines a sendable class.
4195 ///
4196 /// # Arguments
4197 ///
4198 /// * `env` - The environment that the API is invoked under.
4199 ///
4200 /// * `utf8name` - Name of the ArkTS constructor function.
4201 ///
4202 /// * `length` - The length of the utf8name in bytes, or NAPI_AUTO_LENGTH if it is null-terminated.
4203 ///
4204 /// * `constructor` - Callback function that handles constructing instances of the class.
4205 ///
4206 /// * `data` - Optional data to be passed to the constructor callback as the data property of the callback info.
4207 ///
4208 /// * `property_count` - Number of items in the properties array argument.
4209 ///
4210 /// * `properties` - Array of property descriptors describing static and instance data properties, accessors, and
4211 /// methods on the class. See napi_property_descriptor.
4212 ///
4213 /// * `parent` - A napi_value representing the Superclass.
4214 ///
4215 /// * `result` - A napi_value representing the constructor function for the class.
4216 ///
4217 ///
4218 /// # Returns
4219 ///
4220 /// * Return the function execution status.
4221 ///
4222 /// Available since API-level: 12
4223 #[cfg(feature = "api-12")]
4224 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4225 pub fn napi_define_sendable_class(
4226 env: napi_env,
4227 utf8name: *const ::core::ffi::c_char,
4228 length: usize,
4229 constructor: napi_callback,
4230 data: *mut ::core::ffi::c_void,
4231 property_count: usize,
4232 properties: *const napi_property_descriptor,
4233 parent: napi_value,
4234 result: *mut napi_value,
4235 ) -> napi_status;
4236 /// Queries a napi_value to check if it is sendable.
4237 ///
4238 /// # Arguments
4239 ///
4240 /// * `env` - The environment that the API is invoked under.
4241 ///
4242 /// * `value` - The napi_value to be checked.
4243 ///
4244 /// * `result` - Boolean value that is set to true if napi_value is sendable, false otherwise.
4245 ///
4246 ///
4247 /// # Returns
4248 ///
4249 /// * Return the function execution status.
4250 ///
4251 /// Available since API-level: 12
4252 #[cfg(feature = "api-12")]
4253 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4254 pub fn napi_is_sendable(env: napi_env, value: napi_value, result: *mut bool) -> napi_status;
4255 /// Defines a sendable object.
4256 ///
4257 /// # Arguments
4258 ///
4259 /// * `env` - The environment that the API is invoked under.
4260 ///
4261 /// * `property_count` - The count of object properties.
4262 ///
4263 /// * `properties` - Object properties.
4264 ///
4265 /// * `result` - The created sendable object.
4266 ///
4267 ///
4268 /// # Returns
4269 ///
4270 /// * Return the function execution status.
4271 ///
4272 /// Available since API-level: 12
4273 #[cfg(feature = "api-12")]
4274 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4275 pub fn napi_create_sendable_object_with_properties(
4276 env: napi_env,
4277 property_count: usize,
4278 properties: *const napi_property_descriptor,
4279 result: *mut napi_value,
4280 ) -> napi_status;
4281 /// Wraps a native instance in an ArkTS object.
4282 ///
4283 /// # Arguments
4284 ///
4285 /// * `env` - The environment that the API is invoked under.
4286 ///
4287 /// * `js_object` - The ArkTS object that will be the wrapper for the native object.
4288 ///
4289 /// * `native_object` - The native instance that will be wrapped in the ArkTS object.
4290 ///
4291 /// * `finalize_cb` - Optional native callback that can be used to free the native instance when the ArkTS object
4292 /// has been garbage-collected.
4293 ///
4294 /// * `finalize_hint` - Optional contextual hint that is passed to the finalize callback.
4295 ///
4296 ///
4297 /// # Returns
4298 ///
4299 /// * Return the function execution status.
4300 ///
4301 /// Available since API-level: 12
4302 #[cfg(feature = "api-12")]
4303 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4304 pub fn napi_wrap_sendable(
4305 env: napi_env,
4306 js_object: napi_value,
4307 native_object: *mut ::core::ffi::c_void,
4308 finalize_cb: napi_finalize,
4309 finalize_hint: *mut ::core::ffi::c_void,
4310 ) -> napi_status;
4311 /// Wraps a native instance in an ArkTS object.
4312 ///
4313 /// # Arguments
4314 ///
4315 /// * `env` - The environment that the API is invoked under.
4316 ///
4317 /// * `js_object` - The ArkTS object that will be the wrapper for the native object.
4318 ///
4319 /// * `native_object` - The native instance that will be wrapped in the ArkTS object.
4320 ///
4321 /// * `finalize_cb` - Optional native callback that can be used to free the native instance when the ArkTS object
4322 /// has been garbage-collected.
4323 ///
4324 /// * `finalize_hint` - Optional contextual hint that is passed to the finalize callback.
4325 ///
4326 /// * `native_binding_size` - The size of native binding.
4327 ///
4328 ///
4329 /// # Returns
4330 ///
4331 /// * Return the function execution status.
4332 ///
4333 /// Available since API-level: 12
4334 #[cfg(feature = "api-12")]
4335 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4336 pub fn napi_wrap_sendable_with_size(
4337 env: napi_env,
4338 js_object: napi_value,
4339 native_object: *mut ::core::ffi::c_void,
4340 finalize_cb: napi_finalize,
4341 finalize_hint: *mut ::core::ffi::c_void,
4342 native_binding_size: usize,
4343 ) -> napi_status;
4344 /// Retrieves a native instance that was previously wrapped in an ArkTS object.
4345 ///
4346 /// # Arguments
4347 ///
4348 /// * `env` - The environment that the API is invoked under.
4349 ///
4350 /// * `js_object` - The object associated with the native instance.
4351 ///
4352 /// * `result` - Pointer to the wrapped native instance.
4353 ///
4354 ///
4355 /// # Returns
4356 ///
4357 /// * Return the function execution status.
4358 ///
4359 /// Available since API-level: 12
4360 #[cfg(feature = "api-12")]
4361 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4362 pub fn napi_unwrap_sendable(
4363 env: napi_env,
4364 js_object: napi_value,
4365 result: *mut *mut ::core::ffi::c_void,
4366 ) -> napi_status;
4367 /// Retrieves a native instance that was previously wrapped in an ArkTS object and removes the wrapping.
4368 ///
4369 /// # Arguments
4370 ///
4371 /// * `env` - The environment that the API is invoked under.
4372 ///
4373 /// * `js_object` - The object associated with the native instance.
4374 ///
4375 /// * `result` - Pointer to the wrapped native instance.
4376 ///
4377 ///
4378 /// # Returns
4379 ///
4380 /// * Return the function execution status.
4381 ///
4382 /// Available since API-level: 12
4383 #[cfg(feature = "api-12")]
4384 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4385 pub fn napi_remove_wrap_sendable(
4386 env: napi_env,
4387 js_object: napi_value,
4388 result: *mut *mut ::core::ffi::c_void,
4389 ) -> napi_status;
4390 /// Create a sendable array.
4391 ///
4392 /// # Arguments
4393 ///
4394 /// * `env` - The environment that the API is invoked under.
4395 ///
4396 /// * `result` - A napi_value representing a sendable array.
4397 ///
4398 ///
4399 /// # Returns
4400 ///
4401 /// * Return the function execution status.
4402 ///
4403 /// Available since API-level: 12
4404 #[cfg(feature = "api-12")]
4405 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4406 pub fn napi_create_sendable_array(env: napi_env, result: *mut napi_value) -> napi_status;
4407 /// Create a sendable array with length.
4408 ///
4409 /// # Arguments
4410 ///
4411 /// * `env` - The environment that the API is invoked under.
4412 ///
4413 /// * `length` - The initial length of the sendable array.
4414 ///
4415 /// * `result` - A napi_value representing a sendable array.
4416 ///
4417 ///
4418 /// # Returns
4419 ///
4420 /// * Return the function execution status.
4421 ///
4422 /// Available since API-level: 12
4423 #[cfg(feature = "api-12")]
4424 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4425 pub fn napi_create_sendable_array_with_length(
4426 env: napi_env,
4427 length: usize,
4428 result: *mut napi_value,
4429 ) -> napi_status;
4430 /// Create a sendable arraybuffer.
4431 ///
4432 /// # Arguments
4433 ///
4434 /// * `env` - The environment that the API is invoked under.
4435 ///
4436 /// * `byte_length` - The length in bytes of the sendable arraybuffer to create.
4437 ///
4438 /// * `data` - Pointer to the underlying byte buffer of the sendable arraybuffer.
4439 ///
4440 /// * `result` - A napi_value representing a sendable arraybuffer.
4441 ///
4442 ///
4443 /// # Returns
4444 ///
4445 /// * Return the function execution status.
4446 ///
4447 /// Available since API-level: 12
4448 #[cfg(feature = "api-12")]
4449 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4450 pub fn napi_create_sendable_arraybuffer(
4451 env: napi_env,
4452 byte_length: usize,
4453 data: *mut *mut ::core::ffi::c_void,
4454 result: *mut napi_value,
4455 ) -> napi_status;
4456 /// Create a sendable typedarray.
4457 ///
4458 /// # Arguments
4459 ///
4460 /// * `env` - The environment that the API is invoked under.
4461 ///
4462 /// * `type` - Scalar datatype of the elements within the sendable typedarray.
4463 ///
4464 /// * `length` - Number of elements in the typedarray.
4465 ///
4466 /// * `arraybuffer` - Sendable arraybuffer underlying the sendable typedarray.
4467 ///
4468 /// * `byte_offset` - The byte offset within the sendable arraybuffer from which to start projecting the
4469 /// sendable typedarray.
4470 ///
4471 /// * `result` - A napi_value representing a sendable typedarray.
4472 ///
4473 ///
4474 /// # Returns
4475 ///
4476 /// * Return the function execution status.
4477 ///
4478 /// Available since API-level: 12
4479 #[cfg(feature = "api-12")]
4480 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4481 pub fn napi_create_sendable_typedarray(
4482 env: napi_env,
4483 type_: napi_typedarray_type,
4484 length: usize,
4485 arraybuffer: napi_value,
4486 byte_offset: usize,
4487 result: *mut napi_value,
4488 ) -> napi_status;
4489 /// Run the event loop by the given env and running mode in current thread.
4490 ///
4491 /// Support to run the native event loop in an asynchronous native thread with the specified running mode.
4492 ///
4493 /// # Arguments
4494 ///
4495 /// * `env` - Current running virtual machine context.
4496 ///
4497 /// * `mode` - Indicates the running mode of the native event loop.
4498 ///
4499 ///
4500 /// # Returns
4501 ///
4502 /// * Return the function execution status.
4503 ///
4504 /// Available since API-level: 12
4505 #[cfg(feature = "api-12")]
4506 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4507 pub fn napi_run_event_loop(env: napi_env, mode: napi_event_mode) -> napi_status;
4508 /// Stop the event loop in current thread.
4509 ///
4510 /// Support to stop the running event loop in current native thread.
4511 ///
4512 /// # Arguments
4513 ///
4514 /// * `env` - Current running virtual machine context.
4515 ///
4516 ///
4517 /// # Returns
4518 ///
4519 /// * Return the function execution status.
4520 ///
4521 /// Available since API-level: 12
4522 #[cfg(feature = "api-12")]
4523 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4524 pub fn napi_stop_event_loop(env: napi_env) -> napi_status;
4525 /// Serialize an ArkTS object.
4526 ///
4527 /// # Arguments
4528 ///
4529 /// * `env` - Current running virtual machine context.
4530 ///
4531 /// * `object` - The ArkTS object to serialize.
4532 ///
4533 /// * `transfer_list` - List of data to transfer in transfer mode.
4534 ///
4535 /// * `clone_list` - List of Sendable data to transfer in clone mode.
4536 ///
4537 /// * `result` - Serialization result of the ArkTS object.
4538 ///
4539 ///
4540 /// # Returns
4541 ///
4542 /// * Returns the function execution status.
4543 ///
4544 /// Available since API-level: 12
4545 #[cfg(feature = "api-12")]
4546 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4547 pub fn napi_serialize(
4548 env: napi_env,
4549 object: napi_value,
4550 transfer_list: napi_value,
4551 clone_list: napi_value,
4552 result: *mut *mut ::core::ffi::c_void,
4553 ) -> napi_status;
4554 /// Restore serialization data to an ArkTS object.
4555 ///
4556 /// # Arguments
4557 ///
4558 /// * `env` - Current running virtual machine context.
4559 ///
4560 /// * `buffer` - Data to deserialize.
4561 ///
4562 /// * `object` - ArkTS object obtained by deserialization.
4563 ///
4564 ///
4565 /// # Returns
4566 ///
4567 /// * Returns the function execution status.
4568 ///
4569 /// Available since API-level: 12
4570 #[cfg(feature = "api-12")]
4571 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4572 pub fn napi_deserialize(
4573 env: napi_env,
4574 buffer: *mut ::core::ffi::c_void,
4575 object: *mut napi_value,
4576 ) -> napi_status;
4577 /// Delete serialization data.
4578 ///
4579 /// # Arguments
4580 ///
4581 /// * `env` - Current running virtual machine context.
4582 ///
4583 /// * `buffer` - Data to delete.
4584 ///
4585 ///
4586 /// # Returns
4587 ///
4588 /// * Returns the function execution status.
4589 ///
4590 /// Available since API-level: 12
4591 #[cfg(feature = "api-12")]
4592 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4593 pub fn napi_delete_serialization_data(
4594 env: napi_env,
4595 buffer: *mut ::core::ffi::c_void,
4596 ) -> napi_status;
4597 /// Dispatch a task with specified priority from a native thread to an ArkTS thread, the task will execute
4598 /// the given thread safe function.
4599 ///
4600 /// # Arguments
4601 ///
4602 /// * `func` - Indicates the thread safe function.
4603 ///
4604 /// * `data` - Indicates the data anticipated to be transferred to the ArkTS thread.
4605 ///
4606 /// * `priority` - Indicates the priority of the task dispatched.
4607 ///
4608 /// * `isTail` - Indicates the way of the task dispatched into the native event queue. When "isTail" is true,
4609 /// the task will be dispatched to the tail of the native event queue. Conversely, when "isTail" is
4610 /// false, the tasks will be dispatched to the head of the native event queue.
4611 ///
4612 ///
4613 /// # Returns
4614 ///
4615 /// * Return the function execution status.
4616 ///
4617 /// Available since API-level: 12
4618 #[cfg(feature = "api-12")]
4619 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4620 pub fn napi_call_threadsafe_function_with_priority(
4621 func: napi_threadsafe_function,
4622 data: *mut ::core::ffi::c_void,
4623 priority: napi_task_priority,
4624 isTail: bool,
4625 ) -> napi_status;
4626 /// Wraps a native instance in an ArkTS object.
4627 /// # Arguments
4628 ///
4629 /// * `env` - The environment that the API is invoked under.
4630 ///
4631 /// * `js_object` - The ArkTS object that will be the wrapper for the native object.
4632 ///
4633 /// * `native_object` - The native instance that will be wrapped in the ArkTS object.
4634 ///
4635 /// * `finalize_cb` - Optional native callback that can be used to free the native instance when the ArkTS object
4636 /// has been garbage-collected.
4637 ///
4638 /// * `async_finalizer` - A boolean value to determine that finalize_cb execute async or not.
4639 ///
4640 /// * `finalize_hint` - Optional contextual hint that is passed to the finalize callback.
4641 ///
4642 /// * `native_binding_size` - The size of native binding.
4643 ///
4644 /// * `result` - Optional reference to the wrapped object.
4645 ///
4646 ///
4647 /// # Returns
4648 ///
4649 /// * Returns the function execution status.
4650 /// [`napi_ok`] If the function executed successfully.
4651 ///
4652 /// [`napi_invalid_arg`] If the param env, js_object or native_object is nullptr.
4653 ///
4654 /// [`napi_object_expected`] If the param js_object is not an ArkTS Object or Function.
4655 ///
4656 /// [`napi_pending_exception`] There is an uncaught exception occurred before(in) execution.
4657 ///
4658 ///
4659 /// Available since API-level: 18
4660 #[cfg(feature = "api-18")]
4661 #[cfg_attr(docsrs, doc(cfg(feature = "api-18")))]
4662 pub fn napi_wrap_enhance(
4663 env: napi_env,
4664 js_object: napi_value,
4665 native_object: *mut ::core::ffi::c_void,
4666 finalize_cb: napi_finalize,
4667 async_finalizer: bool,
4668 finalize_hint: *mut ::core::ffi::c_void,
4669 native_binding_size: usize,
4670 result: *mut napi_ref,
4671 ) -> napi_status;
4672 /// To create a new virtual machine context.
4673 /// # Arguments
4674 ///
4675 /// * `env` - Current running virtual machine context.
4676 ///
4677 /// * `newEnv` - New generated virtual machine context which is expected to be used later.
4678 ///
4679 ///
4680 /// # Returns
4681 ///
4682 /// * Returns the function execution status.
4683 /// [`napi_ok`] If the function executed successfully.
4684 ///
4685 /// [`napi_invalid_arg`] If the param env is nullptr.
4686 ///
4687 /// [`napi_pending_exception`] If have uncaught exception, or exception occurs in execution.
4688 ///
4689 ///
4690 /// Available since API-level: 20
4691 #[cfg(feature = "api-20")]
4692 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
4693 pub fn napi_create_ark_context(env: napi_env, newEnv: *mut napi_env) -> napi_status;
4694 /// To switch a virtual machine context which is expected to be used later.
4695 /// # Arguments
4696 ///
4697 /// * `env` - Designated Virtual machine context which is expected to be used as the current virtual machine context.
4698 ///
4699 ///
4700 /// # Returns
4701 ///
4702 /// * Returns the function execution status.
4703 /// [`napi_ok`] If the function executed successfully.
4704 ///
4705 /// [`napi_invalid_arg`] If the param env is nullptr.
4706 ///
4707 /// [`napi_pending_exception`] If have uncaught exception, or exception occurs in execution.
4708 ///
4709 ///
4710 /// Available since API-level: 20
4711 #[cfg(feature = "api-20")]
4712 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
4713 pub fn napi_switch_ark_context(env: napi_env) -> napi_status;
4714 /// To destroy a virtual machine context which will not be used again.
4715 /// # Arguments
4716 ///
4717 /// * `env` - Virtual machine context expected to be destroyed.
4718 ///
4719 ///
4720 /// # Returns
4721 ///
4722 /// * Returns the function execution status.
4723 /// [`napi_ok`] If the function executed successfully.
4724 ///
4725 /// [`napi_invalid_arg`] If the param env is nullptr.
4726 ///
4727 /// [`napi_pending_exception`] If have uncaught exception, or exception occurs in execution.
4728 ///
4729 ///
4730 /// Available since API-level: 20
4731 #[cfg(feature = "api-20")]
4732 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
4733 pub fn napi_destroy_ark_context(env: napi_env) -> napi_status;
4734 /// To open a critical scope.
4735 /// # Arguments
4736 ///
4737 /// * `env` - Current running virtual machine context.
4738 ///
4739 /// * `scope` - A critical scope of type of napi_critical_scope is generated.
4740 ///
4741 ///
4742 /// # Returns
4743 ///
4744 /// * Returns the function execution status.
4745 /// [`napi_ok`] If the function executed successfully.
4746 ///
4747 /// [`napi_invalid_arg`] If the param scope is nullptr.
4748 ///
4749 ///
4750 /// Available since API-level: 21
4751 #[cfg(feature = "api-21")]
4752 #[cfg_attr(docsrs, doc(cfg(feature = "api-21")))]
4753 pub fn napi_open_critical_scope(env: napi_env, scope: *mut napi_critical_scope) -> napi_status;
4754 /// To close a critical scope.
4755 /// # Arguments
4756 ///
4757 /// * `env` - Current running virtual machine context.
4758 ///
4759 /// * `scope` - A critical scope to be closed.
4760 ///
4761 ///
4762 /// # Returns
4763 ///
4764 /// * Returns the function execution status.
4765 /// [`napi_ok`] If the function executed successfully.
4766 ///
4767 /// [`napi_invalid_arg`] If the param scope is nullptr.
4768 ///
4769 ///
4770 /// Available since API-level: 21
4771 #[cfg(feature = "api-21")]
4772 #[cfg_attr(docsrs, doc(cfg(feature = "api-21")))]
4773 pub fn napi_close_critical_scope(env: napi_env, scope: napi_critical_scope) -> napi_status;
4774 /// To obtain a ArkTS string buffer cache within the critical scope.
4775 /// # Arguments
4776 ///
4777 /// * `env` - Current running virtual machine context.
4778 ///
4779 /// * `value` - An ArkTS string object which need be encoded with UTF16 format.
4780 ///
4781 /// * `buffer` - String buffer cache of the ArkTS string object value.
4782 ///
4783 /// * `length` - Length size of the string buffer cache which needs to be obtained.
4784 ///
4785 ///
4786 /// # Returns
4787 ///
4788 /// * Returns the function execution status.
4789 /// [`napi_ok`] If the function executed successfully.
4790 ///
4791 /// [`napi_invalid_arg`] If the param env, value, buffer and length is nullptr.
4792 ///
4793 ///
4794 /// Available since API-level: 21
4795 #[cfg(feature = "api-21")]
4796 #[cfg_attr(docsrs, doc(cfg(feature = "api-21")))]
4797 pub fn napi_get_buffer_string_utf16_in_critical_scope(
4798 env: napi_env,
4799 value: napi_value,
4800 buffer: *mut *const char16_t,
4801 length: *mut usize,
4802 ) -> napi_status;
4803 /// Creates a strong reference for an ArkTS object to extend its lifespan. The caller needs to manage the
4804 /// reference lifespan.
4805 /// # Arguments
4806 ///
4807 /// * `env` - Current running virtual machine context.
4808 ///
4809 /// * `value` - The napi_value that is being referenced.
4810 ///
4811 /// * `result` - napi_strong_ref pointing to the new strong reference.
4812 ///
4813 ///
4814 /// # Returns
4815 ///
4816 /// * Returns the function execution status.
4817 /// [`napi_ok`] If the function executed successfully.
4818 ///
4819 /// [`napi_invalid_arg`] If env, value or result is nullptr.
4820 ///
4821 ///
4822 /// Available since API-level: 21
4823 #[cfg(feature = "api-21")]
4824 #[cfg_attr(docsrs, doc(cfg(feature = "api-21")))]
4825 pub fn napi_create_strong_reference(
4826 env: napi_env,
4827 value: napi_value,
4828 result: *mut napi_strong_ref,
4829 ) -> napi_status;
4830 /// Deletes the strong reference passed in.
4831 /// # Arguments
4832 ///
4833 /// * `env` - Current running virtual machine context.
4834 ///
4835 /// * `ref` - The napi_strong_ref to be deleted.
4836 ///
4837 ///
4838 /// # Returns
4839 ///
4840 /// * Returns the function execution status.
4841 /// [`napi_ok`] If the function executed successfully.
4842 ///
4843 /// [`napi_invalid_arg`] If env or ref is nullptr.
4844 ///
4845 ///
4846 /// Available since API-level: 21
4847 #[cfg(feature = "api-21")]
4848 #[cfg_attr(docsrs, doc(cfg(feature = "api-21")))]
4849 pub fn napi_delete_strong_reference(env: napi_env, ref_: napi_strong_ref) -> napi_status;
4850 /// Obtains the ArkTS Object associated with the strong reference.
4851 /// # Arguments
4852 ///
4853 /// * `env` - Current running virtual machine context.
4854 ///
4855 /// * `ref` - The napi_strong_ref of the value being requested.
4856 ///
4857 /// * `result` - The napi_value referenced by the napi_strong_ref.
4858 ///
4859 ///
4860 /// # Returns
4861 ///
4862 /// * Returns the function execution status.
4863 /// [`napi_ok`] If the function executed successfully.
4864 ///
4865 /// [`napi_invalid_arg`] If env, ref or result is nullptr.
4866 ///
4867 ///
4868 /// Available since API-level: 21
4869 #[cfg(feature = "api-21")]
4870 #[cfg_attr(docsrs, doc(cfg(feature = "api-21")))]
4871 pub fn napi_get_strong_reference_value(
4872 env: napi_env,
4873 ref_: napi_strong_ref,
4874 result: *mut napi_value,
4875 ) -> napi_status;
4876 /// Creates an ArkTS string from a UTF16-encoded C string.
4877 /// # Arguments
4878 ///
4879 /// * `env` - Current running virtual machine context.
4880 ///
4881 /// * `str` - C string encoded in UTF16 format.
4882 ///
4883 /// * `length` - The length of the C string 'str'.
4884 ///
4885 /// * `finalize_callback` - Native finalize callback used to recycle native resource.
4886 ///
4887 /// * `finalize_hint` - Optional contextual hint that is passed to the finalize_callback.
4888 ///
4889 /// * `result` - Result of the ArkTS string from the UTF16-encoded C string.
4890 ///
4891 ///
4892 /// # Returns
4893 ///
4894 /// * Returns the function execution status.
4895 /// [`napi_ok`] If the function executed successfully.
4896 ///
4897 /// [`napi_invalid_arg`] If the param env, str and(or) result is nullptr;
4898 ///
4899 /// If the param length is not equal with NAPI_AUTO_LENGTH and
4900 ///
4901 /// length is larger than INT_MAX;
4902 ///
4903 ///
4904 /// Available since API-level: 22
4905 #[cfg(feature = "api-22")]
4906 #[cfg_attr(docsrs, doc(cfg(feature = "api-22")))]
4907 pub fn napi_create_external_string_utf16(
4908 env: napi_env,
4909 str_: *const char16_t,
4910 length: usize,
4911 finalize_callback: napi_finalize_callback,
4912 finalize_hint: *mut ::core::ffi::c_void,
4913 result: *mut napi_value,
4914 ) -> napi_status;
4915 /// Creates an ArkTS string from a ASCII-encoded C string.
4916 /// # Arguments
4917 ///
4918 /// * `env` - Current running virtual machine context.
4919 ///
4920 /// * `str` - C string encoded in ASCII format.
4921 ///
4922 /// * `length` - The length of the C string 'str'.
4923 ///
4924 /// * `finalize_callback` - Native finalize callback used to recycle native resource.
4925 ///
4926 /// * `finalize_hint` - Optional contextual hint that is passed to the finalize_callback.
4927 ///
4928 /// * `result` - Result of the ArkTS string from the ASCII-encoded C string.
4929 ///
4930 ///
4931 /// # Returns
4932 ///
4933 /// * Returns the function execution status.
4934 /// [`napi_ok`] If the function executed successfully.
4935 ///
4936 /// [`napi_invalid_arg`] If the param env, str and(or) result is nullptr;
4937 ///
4938 /// If the param length is not equal with NAPI_AUTO_LENGTH and
4939 ///
4940 /// length is larger than INT_MAX;
4941 ///
4942 ///
4943 /// Available since API-level: 22
4944 #[cfg(feature = "api-22")]
4945 #[cfg_attr(docsrs, doc(cfg(feature = "api-22")))]
4946 pub fn napi_create_external_string_ascii(
4947 env: napi_env,
4948 str_: *const ::core::ffi::c_char,
4949 length: usize,
4950 finalize_callback: napi_finalize_callback,
4951 finalize_hint: *mut ::core::ffi::c_void,
4952 result: *mut napi_value,
4953 ) -> napi_status;
4954 /// Creates a strong sendable reference for an ArkTS object to extend its lifespan. The caller needs to manage
4955 /// the sendable reference lifespan.
4956 /// # Arguments
4957 ///
4958 /// * `env` - Current running virtual machine context.
4959 ///
4960 /// * `value` - The sendable ArkTS object that is being referenced.
4961 ///
4962 /// * `result` - The napi_sendable_ref pointing to the new strong sendable reference.
4963 ///
4964 ///
4965 /// # Returns
4966 ///
4967 /// * Returns the function execution status.
4968 /// [`napi_ok`] If the function executed successfully.
4969 ///
4970 /// [`napi_invalid_arg`] If env, value or result is nullptr.
4971 ///
4972 ///
4973 /// Available since API-level: 22
4974 #[cfg(feature = "api-22")]
4975 #[cfg_attr(docsrs, doc(cfg(feature = "api-22")))]
4976 pub fn napi_create_strong_sendable_reference(
4977 env: napi_env,
4978 value: napi_value,
4979 result: *mut napi_sendable_ref,
4980 ) -> napi_status;
4981 /// Deletes the strong sendable reference passed in.
4982 /// # Arguments
4983 ///
4984 /// * `env` - Current running virtual machine context.
4985 ///
4986 /// * `ref` - The sendable reference to be deleted.
4987 ///
4988 ///
4989 /// # Returns
4990 ///
4991 /// * Returns the function execution status.
4992 /// [`napi_ok`] If the function executed successfully.
4993 ///
4994 /// [`napi_invalid_arg`] If env or ref is nullptr.
4995 ///
4996 ///
4997 /// Available since API-level: 22
4998 #[cfg(feature = "api-22")]
4999 #[cfg_attr(docsrs, doc(cfg(feature = "api-22")))]
5000 pub fn napi_delete_strong_sendable_reference(
5001 env: napi_env,
5002 ref_: napi_sendable_ref,
5003 ) -> napi_status;
5004 /// Obtains the ArkTS Object associated with the strong reference.
5005 /// # Arguments
5006 ///
5007 /// * `env` - Current running virtual machine context.
5008 ///
5009 /// * `ref` - The sendable reference of the sendable object value being requested.
5010 ///
5011 /// * `result` - The sendable ArkTS object referenced by the sendable reference.
5012 ///
5013 ///
5014 /// # Returns
5015 ///
5016 /// * Returns the function execution status.
5017 /// [`napi_ok`] If the function executed successfully.
5018 ///
5019 /// [`napi_invalid_arg`] If env, ref or result is nullptr.
5020 ///
5021 ///
5022 /// Available since API-level: 22
5023 #[cfg(feature = "api-22")]
5024 #[cfg_attr(docsrs, doc(cfg(feature = "api-22")))]
5025 pub fn napi_get_strong_sendable_reference_value(
5026 env: napi_env,
5027 ref_: napi_sendable_ref,
5028 result: *mut napi_value,
5029 ) -> napi_status;
5030 /// Throws an ArkTS Error with text information.
5031 /// # Arguments
5032 ///
5033 /// * `env` - Current running virtual machine context.
5034 ///
5035 /// * `errorCode` - Error code to be set on the error object.
5036 ///
5037 /// * `msg` - C string representing the text to be associated with the error object.
5038 ///
5039 ///
5040 /// # Returns
5041 ///
5042 /// * Returns the function execution status.
5043 /// [`napi_ok`] If the function executed successfully.
5044 ///
5045 /// [`napi_invalid_arg`] If env or msg is nullptr.
5046 ///
5047 /// [`napi_pending_exception`] There is an uncaught exception occurred before execution.
5048 ///
5049 ///
5050 /// Available since API-level: 23
5051 #[cfg(feature = "api-23")]
5052 #[cfg_attr(docsrs, doc(cfg(feature = "api-23")))]
5053 pub fn napi_throw_business_error(
5054 env: napi_env,
5055 errorCode: i32,
5056 msg: *const ::core::ffi::c_char,
5057 ) -> napi_status;
5058}