nodex_api/value/
null.rs

1use crate::{api, prelude::*};
2use std::{mem::MaybeUninit, os::raw::c_char};
3
4#[derive(Copy, Clone, Debug)]
5pub struct JsNull(pub(crate) JsValue);
6
7impl JsNull {
8    pub(crate) fn from_value(value: JsValue) -> JsNull {
9        JsNull(value)
10    }
11
12    /// This API returns the null object.
13    pub fn new(env: NapiEnv) -> NapiResult<JsNull> {
14        let value = napi_call!(=napi_get_null, env);
15        Ok(JsNull(JsValue::from_raw(env, value)))
16    }
17}
18
19napi_value_t!(JsNull);
20
21impl NapiValueCheck for JsNull {
22    fn check(&self) -> NapiResult<bool> {
23        Ok(self.kind()? == NapiValuetype::Null)
24    }
25}