neon/sys/bindings/
types.rs

1use std::ffi::c_void;
2
3#[repr(C)]
4#[derive(Debug, Copy, Clone)]
5#[doc(hidden)]
6pub struct Env__ {
7    _unused: [u8; 0],
8}
9
10#[cfg_attr(docsrs, doc(cfg(feature = "napi-1")))]
11/// [`napi_env`](https://nodejs.org/api/n-api.html#napi_env)
12pub type Env = *mut Env__;
13
14#[repr(C)]
15#[derive(Debug, Copy, Clone)]
16#[doc(hidden)]
17pub struct Value__ {
18    _unused: [u8; 0],
19}
20
21#[cfg_attr(docsrs, doc(cfg(feature = "napi-1")))]
22/// [`napi_value`](https://nodejs.org/api/n-api.html#napi_value)
23pub type Value = *mut Value__;
24
25#[repr(C)]
26#[derive(Debug, Copy, Clone)]
27#[doc(hidden)]
28pub struct CallbackInfo__ {
29    _unused: [u8; 0],
30}
31
32#[cfg_attr(docsrs, doc(cfg(feature = "napi-1")))]
33/// [`napi_callback_info`](https://nodejs.org/api/n-api.html#napi_callback_info)
34pub type CallbackInfo = *mut CallbackInfo__;
35
36#[repr(C)]
37#[derive(Debug, Copy, Clone)]
38#[doc(hidden)]
39pub struct EscapableHandleScope__ {
40    _unused: [u8; 0],
41}
42
43#[cfg_attr(docsrs, doc(cfg(feature = "napi-1")))]
44/// [`napi_escapable_handle_scope`](https://nodejs.org/api/n-api.html#napi_escapable_handle_scope)
45pub type EscapableHandleScope = *mut EscapableHandleScope__;
46
47#[repr(C)]
48#[derive(Debug, Copy, Clone)]
49#[doc(hidden)]
50pub struct HandleScope__ {
51    _unused: [u8; 0],
52}
53
54#[cfg_attr(docsrs, doc(cfg(feature = "napi-1")))]
55/// [`napi_handle_scope`](https://nodejs.org/api/n-api.html#napi_handle_scope)
56pub type HandleScope = *mut HandleScope__;
57
58#[repr(C)]
59#[derive(Debug, Copy, Clone)]
60#[doc(hidden)]
61pub struct Ref__ {
62    _unused: [u8; 0],
63}
64
65#[cfg_attr(docsrs, doc(cfg(feature = "napi-1")))]
66/// [`napi_ref`](https://nodejs.org/api/n-api.html#napi_ref)
67pub type Ref = *mut Ref__;
68
69#[cfg(feature = "napi-4")]
70#[repr(C)]
71#[derive(Debug, Copy, Clone)]
72#[doc(hidden)]
73pub struct ThreadsafeFunction__ {
74    _unused: [u8; 0],
75}
76
77#[cfg_attr(docsrs, doc(cfg(feature = "napi-4")))]
78#[cfg(feature = "napi-4")]
79/// [`napi_threadsafe_function`](https://nodejs.org/api/n-api.html#napi_threadsafe_function)
80pub type ThreadsafeFunction = *mut ThreadsafeFunction__;
81
82#[cfg_attr(docsrs, doc(cfg(feature = "napi-1")))]
83/// [`napi_callback`](https://nodejs.org/api/n-api.html#napi_callback)
84pub type Callback = Option<unsafe extern "C" fn(env: Env, info: CallbackInfo) -> Value>;
85
86#[cfg_attr(docsrs, doc(cfg(feature = "napi-1")))]
87/// [`napi_finalize`](https://nodejs.org/api/n-api.html#napi_finalize)
88pub type Finalize =
89    Option<unsafe extern "C" fn(env: Env, finalize_data: *mut c_void, finalize_hint: *mut c_void)>;
90
91#[cfg_attr(docsrs, doc(cfg(feature = "napi-4")))]
92#[cfg(feature = "napi-4")]
93/// [`napi_threadsafe_function_call_js`](https://nodejs.org/api/n-api.html#napi_threadsafe_function_call_js)
94pub type ThreadsafeFunctionCallJs = Option<
95    unsafe extern "C" fn(env: Env, js_callback: Value, context: *mut c_void, data: *mut c_void),
96>;
97
98#[allow(dead_code)]
99#[repr(u32)]
100#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
101#[cfg_attr(docsrs, doc(cfg(feature = "napi-1")))]
102/// [`napi_status`](https://nodejs.org/api/n-api.html#napi_status)
103pub enum Status {
104    Ok = 0,
105    InvalidArg = 1,
106    ObjectExpected = 2,
107    StringExpected = 3,
108    NameExpected = 4,
109    FunctionExpected = 5,
110    NumberExpected = 6,
111    BooleanExpected = 7,
112    ArrayExpected = 8,
113    GenericFailure = 9,
114    PendingException = 10,
115    Cancelled = 11,
116    EscapeCalledTwice = 12,
117    HandleScopeMismatch = 13,
118    CallbackScopeMismatch = 14,
119    QueueFull = 15,
120    Closing = 16,
121    BigintExpected = 17,
122    DateExpected = 18,
123    ArraybufferExpected = 19,
124    DetachableArraybufferExpected = 20,
125    WouldDeadlock = 21,
126}
127
128#[allow(dead_code)]
129#[repr(u32)]
130#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
131#[cfg_attr(docsrs, doc(cfg(feature = "napi-6")))]
132/// [`napi_valuetype`](https://nodejs.org/api/n-api.html#napi_valuetype)
133pub enum ValueType {
134    Undefined = 0,
135    Null = 1,
136    Boolean = 2,
137    Number = 3,
138    String = 4,
139    Symbol = 5,
140    Object = 6,
141    Function = 7,
142    External = 8,
143    BigInt = 9,
144}
145
146#[allow(dead_code)]
147#[repr(u32)]
148#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
149#[cfg_attr(docsrs, doc(cfg(feature = "napi-1")))]
150/// [`napi_typedarray_type`](https://nodejs.org/api/n-api.html#napi_typedarray_type)
151pub enum TypedArrayType {
152    I8 = 0,
153    U8 = 1,
154    U8Clamped = 2,
155    I16 = 3,
156    U16 = 4,
157    I32 = 5,
158    U32 = 6,
159    F32 = 7,
160    F64 = 8,
161    I64 = 9,
162    U64 = 10,
163}
164
165#[allow(dead_code)]
166#[repr(u32)]
167#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
168#[cfg_attr(docsrs, doc(cfg(feature = "napi-6")))]
169#[cfg(feature = "napi-6")]
170/// [`napi_key_collection_mode`](https://nodejs.org/api/n-api.html#napi_key_collection_mode)
171pub enum KeyCollectionMode {
172    IncludePrototypes = 0,
173    OwnOnly = 1,
174}
175
176#[allow(dead_code)]
177#[repr(u32)]
178#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
179#[cfg_attr(docsrs, doc(cfg(feature = "napi-6")))]
180#[cfg(feature = "napi-6")]
181/// [`napi_key_conversion`](https://nodejs.org/api/n-api.html#napi_key_conversion)
182pub enum KeyConversion {
183    KeepNumbers = 0,
184    NumbersToStrings = 1,
185}
186
187#[cfg_attr(docsrs, doc(cfg(feature = "napi-4")))]
188#[cfg(feature = "napi-4")]
189#[allow(dead_code)]
190#[repr(u32)]
191#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
192/// [`napi_threadsafe_function_call_mode`](https://nodejs.org/api/n-api.html#napi_threadsafe_function_call_mode)
193pub enum ThreadsafeFunctionCallMode {
194    NonBlocking = 0,
195    Blocking = 1,
196}
197
198#[cfg_attr(docsrs, doc(cfg(feature = "napi-4")))]
199#[cfg(feature = "napi-4")]
200#[allow(dead_code)]
201#[repr(u32)]
202#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
203/// [`napi_threadsafe_function_release_mode`](https://nodejs.org/api/n-api.html#napi_threadsafe_function_release_mode)
204pub enum ThreadsafeFunctionReleaseMode {
205    Release = 0,
206    Abort = 1,
207}
208
209#[repr(transparent)]
210#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
211#[cfg_attr(docsrs, doc(cfg(feature = "napi-6")))]
212#[cfg(feature = "napi-6")]
213/// [`napi_key_filter`](https://nodejs.org/api/n-api.html#napi_key_filter)
214pub struct KeyFilter(pub ::std::os::raw::c_uint);
215
216#[allow(dead_code)]
217#[cfg(feature = "napi-6")]
218impl KeyFilter {
219    pub const ALL_PROPERTIES: KeyFilter = KeyFilter(0);
220    pub const WRITABLE: KeyFilter = KeyFilter(1);
221    pub const CONFIGURABLE: KeyFilter = KeyFilter(4);
222    pub const SKIP_STRINGS: KeyFilter = KeyFilter(8);
223    pub const SKIP_SYMBOLS: KeyFilter = KeyFilter(16);
224}
225
226#[cfg(feature = "napi-6")]
227impl std::ops::BitOr<KeyFilter> for KeyFilter {
228    type Output = Self;
229    #[inline]
230    fn bitor(self, other: Self) -> Self {
231        KeyFilter(self.0 | other.0)
232    }
233}
234
235#[cfg(feature = "napi-6")]
236impl std::ops::BitOrAssign for KeyFilter {
237    #[inline]
238    fn bitor_assign(&mut self, rhs: KeyFilter) {
239        self.0 |= rhs.0;
240    }
241}
242
243#[cfg(feature = "napi-6")]
244impl std::ops::BitAnd<KeyFilter> for KeyFilter {
245    type Output = Self;
246    #[inline]
247    fn bitand(self, other: Self) -> Self {
248        KeyFilter(self.0 & other.0)
249    }
250}
251
252#[cfg(feature = "napi-6")]
253impl std::ops::BitAndAssign for KeyFilter {
254    #[inline]
255    fn bitand_assign(&mut self, rhs: KeyFilter) {
256        self.0 &= rhs.0;
257    }
258}
259
260#[repr(C)]
261#[derive(Debug, Copy, Clone)]
262#[doc(hidden)]
263pub struct AsyncWork__ {
264    _unused: [u8; 0],
265}
266
267#[cfg_attr(docsrs, doc(cfg(feature = "napi-1")))]
268/// [`napi_async_work`](https://nodejs.org/api/n-api.html#napi_async_work)
269pub type AsyncWork = *mut AsyncWork__;
270
271#[cfg_attr(docsrs, doc(cfg(feature = "napi-1")))]
272/// [`napi_async_execute_callback`](https://nodejs.org/api/n-api.html#napi_async_execute_callback)
273pub type AsyncExecuteCallback = Option<unsafe extern "C" fn(env: Env, data: *mut c_void)>;
274
275#[cfg_attr(docsrs, doc(cfg(feature = "napi-1")))]
276/// [`napi_async_complete_callback`](https://nodejs.org/api/n-api.html#napi_async_complete_callback)
277pub type AsyncCompleteCallback =
278    Option<unsafe extern "C" fn(env: Env, status: Status, data: *mut c_void)>;
279
280#[repr(C)]
281#[derive(Debug, Copy, Clone)]
282#[doc(hidden)]
283pub struct Deferred__ {
284    _unused: [u8; 0],
285}
286
287#[cfg_attr(docsrs, doc(cfg(feature = "napi-1")))]
288/// [`napi_deferred`](https://nodejs.org/api/n-api.html#napi_deferred)
289pub type Deferred = *mut Deferred__;
290
291#[cfg_attr(docsrs, doc(cfg(feature = "napi-8")))]
292#[cfg(feature = "napi-8")]
293#[repr(C)]
294#[derive(Debug, Copy, Clone)]
295/// [`napi_type_tag`](https://nodejs.org/api/n-api.html#napi_type_tag)
296pub struct TypeTag {
297    pub lower: u64,
298    pub upper: u64,
299}