1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
use std::ffi::c_void;

#[repr(C)]
#[derive(Debug, Copy, Clone)]
#[doc(hidden)]
pub struct Env__ {
    _unused: [u8; 0],
}

#[cfg_attr(docsrs, doc(cfg(feature = "napi-1")))]
/// [`napi_env`](https://nodejs.org/api/n-api.html#napi_env)
pub type Env = *mut Env__;

#[repr(C)]
#[derive(Debug, Copy, Clone)]
#[doc(hidden)]
pub struct Value__ {
    _unused: [u8; 0],
}

#[cfg_attr(docsrs, doc(cfg(feature = "napi-1")))]
/// [`napi_value`](https://nodejs.org/api/n-api.html#napi_value)
pub type Value = *mut Value__;

#[repr(C)]
#[derive(Debug, Copy, Clone)]
#[doc(hidden)]
pub struct CallbackInfo__ {
    _unused: [u8; 0],
}

#[cfg_attr(docsrs, doc(cfg(feature = "napi-1")))]
/// [`napi_callback_info`](https://nodejs.org/api/n-api.html#napi_callback_info)
pub type CallbackInfo = *mut CallbackInfo__;

#[repr(C)]
#[derive(Debug, Copy, Clone)]
#[doc(hidden)]
pub struct EscapableHandleScope__ {
    _unused: [u8; 0],
}

#[cfg_attr(docsrs, doc(cfg(feature = "napi-1")))]
/// [`napi_escapable_handle_scope`](https://nodejs.org/api/n-api.html#napi_escapable_handle_scope)
pub type EscapableHandleScope = *mut EscapableHandleScope__;

#[repr(C)]
#[derive(Debug, Copy, Clone)]
#[doc(hidden)]
pub struct HandleScope__ {
    _unused: [u8; 0],
}

#[cfg_attr(docsrs, doc(cfg(feature = "napi-1")))]
/// [`napi_handle_scope`](https://nodejs.org/api/n-api.html#napi_handle_scope)
pub type HandleScope = *mut HandleScope__;

#[repr(C)]
#[derive(Debug, Copy, Clone)]
#[doc(hidden)]
pub struct Ref__ {
    _unused: [u8; 0],
}

#[cfg_attr(docsrs, doc(cfg(feature = "napi-1")))]
/// [`napi_ref`](https://nodejs.org/api/n-api.html#napi_ref)
pub type Ref = *mut Ref__;

#[cfg(feature = "napi-4")]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
#[doc(hidden)]
pub struct ThreadsafeFunction__ {
    _unused: [u8; 0],
}

#[cfg_attr(docsrs, doc(cfg(feature = "napi-4")))]
#[cfg(feature = "napi-4")]
/// [`napi_threadsafe_function`](https://nodejs.org/api/n-api.html#napi_threadsafe_function)
pub type ThreadsafeFunction = *mut ThreadsafeFunction__;

#[cfg_attr(docsrs, doc(cfg(feature = "napi-1")))]
/// [`napi_callback`](https://nodejs.org/api/n-api.html#napi_callback)
pub type Callback = Option<unsafe extern "C" fn(env: Env, info: CallbackInfo) -> Value>;

#[cfg_attr(docsrs, doc(cfg(feature = "napi-1")))]
/// [`napi_finalize`](https://nodejs.org/api/n-api.html#napi_finalize)
pub type Finalize =
    Option<unsafe extern "C" fn(env: Env, finalize_data: *mut c_void, finalize_hint: *mut c_void)>;

#[cfg_attr(docsrs, doc(cfg(feature = "napi-4")))]
#[cfg(feature = "napi-4")]
/// [`napi_threadsafe_function_call_js`](https://nodejs.org/api/n-api.html#napi_threadsafe_function_call_js)
pub type ThreadsafeFunctionCallJs = Option<
    unsafe extern "C" fn(env: Env, js_callback: Value, context: *mut c_void, data: *mut c_void),
>;

#[allow(dead_code)]
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(docsrs, doc(cfg(feature = "napi-1")))]
/// [`napi_status`](https://nodejs.org/api/n-api.html#napi_status)
pub enum Status {
    Ok = 0,
    InvalidArg = 1,
    ObjectExpected = 2,
    StringExpected = 3,
    NameExpected = 4,
    FunctionExpected = 5,
    NumberExpected = 6,
    BooleanExpected = 7,
    ArrayExpected = 8,
    GenericFailure = 9,
    PendingException = 10,
    Cancelled = 11,
    EscapeCalledTwice = 12,
    HandleScopeMismatch = 13,
    CallbackScopeMismatch = 14,
    QueueFull = 15,
    Closing = 16,
    BigintExpected = 17,
    DateExpected = 18,
    ArraybufferExpected = 19,
    DetachableArraybufferExpected = 20,
    WouldDeadlock = 21,
}

#[allow(dead_code)]
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(docsrs, doc(cfg(feature = "napi-6")))]
/// [`napi_valuetype`](https://nodejs.org/api/n-api.html#napi_valuetype)
pub enum ValueType {
    Undefined = 0,
    Null = 1,
    Boolean = 2,
    Number = 3,
    String = 4,
    Symbol = 5,
    Object = 6,
    Function = 7,
    External = 8,
    BigInt = 9,
}

#[allow(dead_code)]
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(docsrs, doc(cfg(feature = "napi-1")))]
/// [`napi_typedarray_type`](https://nodejs.org/api/n-api.html#napi_typedarray_type)
pub enum TypedArrayType {
    I8 = 0,
    U8 = 1,
    U8Clamped = 2,
    I16 = 3,
    U16 = 4,
    I32 = 5,
    U32 = 6,
    F32 = 7,
    F64 = 8,
    I64 = 9,
    U64 = 10,
}

#[allow(dead_code)]
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(docsrs, doc(cfg(feature = "napi-6")))]
#[cfg(feature = "napi-6")]
/// [`napi_key_collection_mode`](https://nodejs.org/api/n-api.html#napi_key_collection_mode)
pub enum KeyCollectionMode {
    IncludePrototypes = 0,
    OwnOnly = 1,
}

#[allow(dead_code)]
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(docsrs, doc(cfg(feature = "napi-6")))]
#[cfg(feature = "napi-6")]
/// [`napi_key_conversion`](https://nodejs.org/api/n-api.html#napi_key_conversion)
pub enum KeyConversion {
    KeepNumbers = 0,
    NumbersToStrings = 1,
}

#[cfg_attr(docsrs, doc(cfg(feature = "napi-4")))]
#[cfg(feature = "napi-4")]
#[allow(dead_code)]
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
/// [`napi_threadsafe_function_call_mode`](https://nodejs.org/api/n-api.html#napi_threadsafe_function_call_mode)
pub enum ThreadsafeFunctionCallMode {
    NonBlocking = 0,
    Blocking = 1,
}

#[cfg_attr(docsrs, doc(cfg(feature = "napi-4")))]
#[cfg(feature = "napi-4")]
#[allow(dead_code)]
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
/// [`napi_threadsafe_function_release_mode`](https://nodejs.org/api/n-api.html#napi_threadsafe_function_release_mode)
pub enum ThreadsafeFunctionReleaseMode {
    Release = 0,
    Abort = 1,
}

#[repr(transparent)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(docsrs, doc(cfg(feature = "napi-6")))]
#[cfg(feature = "napi-6")]
/// [`napi_key_filter`](https://nodejs.org/api/n-api.html#napi_key_filter)
pub struct KeyFilter(pub ::std::os::raw::c_uint);

#[allow(dead_code)]
#[cfg(feature = "napi-6")]
impl KeyFilter {
    pub const ALL_PROPERTIES: KeyFilter = KeyFilter(0);
    pub const WRITABLE: KeyFilter = KeyFilter(1);
    pub const CONFIGURABLE: KeyFilter = KeyFilter(4);
    pub const SKIP_STRINGS: KeyFilter = KeyFilter(8);
    pub const SKIP_SYMBOLS: KeyFilter = KeyFilter(16);
}

#[cfg(feature = "napi-6")]
impl std::ops::BitOr<KeyFilter> for KeyFilter {
    type Output = Self;
    #[inline]
    fn bitor(self, other: Self) -> Self {
        KeyFilter(self.0 | other.0)
    }
}

#[cfg(feature = "napi-6")]
impl std::ops::BitOrAssign for KeyFilter {
    #[inline]
    fn bitor_assign(&mut self, rhs: KeyFilter) {
        self.0 |= rhs.0;
    }
}

#[cfg(feature = "napi-6")]
impl std::ops::BitAnd<KeyFilter> for KeyFilter {
    type Output = Self;
    #[inline]
    fn bitand(self, other: Self) -> Self {
        KeyFilter(self.0 & other.0)
    }
}

#[cfg(feature = "napi-6")]
impl std::ops::BitAndAssign for KeyFilter {
    #[inline]
    fn bitand_assign(&mut self, rhs: KeyFilter) {
        self.0 &= rhs.0;
    }
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
#[doc(hidden)]
pub struct AsyncWork__ {
    _unused: [u8; 0],
}

#[cfg_attr(docsrs, doc(cfg(feature = "napi-1")))]
/// [`napi_async_work`](https://nodejs.org/api/n-api.html#napi_async_work)
pub type AsyncWork = *mut AsyncWork__;

#[cfg_attr(docsrs, doc(cfg(feature = "napi-1")))]
/// [`napi_async_execute_callback`](https://nodejs.org/api/n-api.html#napi_async_execute_callback)
pub type AsyncExecuteCallback = Option<unsafe extern "C" fn(env: Env, data: *mut c_void)>;

#[cfg_attr(docsrs, doc(cfg(feature = "napi-1")))]
/// [`napi_async_complete_callback`](https://nodejs.org/api/n-api.html#napi_async_complete_callback)
pub type AsyncCompleteCallback =
    Option<unsafe extern "C" fn(env: Env, status: Status, data: *mut c_void)>;

#[repr(C)]
#[derive(Debug, Copy, Clone)]
#[doc(hidden)]
pub struct Deferred__ {
    _unused: [u8; 0],
}

#[cfg_attr(docsrs, doc(cfg(feature = "napi-1")))]
/// [`napi_deferred`](https://nodejs.org/api/n-api.html#napi_deferred)
pub type Deferred = *mut Deferred__;

#[cfg_attr(docsrs, doc(cfg(feature = "napi-8")))]
#[cfg(feature = "napi-8")]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
/// [`napi_type_tag`](https://nodejs.org/api/n-api.html#napi_type_tag)
pub struct TypeTag {
    pub lower: u64,
    pub upper: u64,
}