pub struct JsExternal<'env>(/* private fields */);Expand description
Represent the Node-API External value
The difference between the JsExternal and External is that the JsExternal holds the raw value of External.
So that you can call Object::set_property with the JsExternal value, but can’t do the same with External.
Implementations§
Source§impl<'env> JsExternal<'env>
impl<'env> JsExternal<'env>
Sourcepub fn get_value<T: 'static>(&self) -> Result<&mut T>
pub fn get_value<T: 'static>(&self) -> Result<&mut T>
Get the value from the JsExternal
If the underlying value is not T, it will return InvalidArg error.
Sourcepub fn create_ref<T: 'static>(&self) -> Result<ExternalRef<T>>
pub fn create_ref<T: 'static>(&self) -> Result<ExternalRef<T>>
Create a reference to the JsExternal
If the underlying value is not T, it will return InvalidArg error.
Trait Implementations§
Source§impl<'env> FromNapiValue for JsExternal<'env>
impl<'env> FromNapiValue for JsExternal<'env>
Source§unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
Safety Read more
fn from_unknown(value: Unknown<'_>) -> Result<Self>
Source§impl<'env> JsValue<'env> for JsExternal<'env>
impl<'env> JsValue<'env> for JsExternal<'env>
fn value(&self) -> Value
fn raw(&self) -> napi_value
Source§fn to_unknown(&self) -> Unknown<'env>
fn to_unknown(&self) -> Unknown<'env>
Convert the value to an unknown
Source§fn coerce_to_bool(&self) -> Result<bool>
fn coerce_to_bool(&self) -> Result<bool>
Coerce the value to a boolean
fn coerce_to_number(&self) -> Result<JsNumber<'_>>
fn coerce_to_string(&self) -> Result<JsString<'_>>
fn coerce_to_object(&self) -> Result<Object<'env>>
fn is_date(&self) -> Result<bool>
fn is_promise(&self) -> Result<bool>
fn is_error(&self) -> Result<bool>
fn is_typedarray(&self) -> Result<bool>
fn is_dataview(&self) -> Result<bool>
fn is_array(&self) -> Result<bool>
fn is_buffer(&self) -> Result<bool>
fn is_arraybuffer(&self) -> Result<bool>
fn instanceof<'c, Constructor>(&self, constructor: Constructor) -> Result<bool>where
Constructor: JsValue<'c>,
fn escape<'scope, E: JsValue<'scope> + FromNapiValue>( &self, escapable_handle_scope: EscapableHandleScope<'scope>, ) -> Result<E>
Source§impl<'env> TypeName for JsExternal<'env>
impl<'env> TypeName for JsExternal<'env>
Source§impl<'env> ValidateNapiValue for JsExternal<'env>
impl<'env> ValidateNapiValue for JsExternal<'env>
Source§unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
Safety Read more
Auto Trait Implementations§
impl<'env> Freeze for JsExternal<'env>
impl<'env> RefUnwindSafe for JsExternal<'env>
impl<'env> !Send for JsExternal<'env>
impl<'env> !Sync for JsExternal<'env>
impl<'env> Unpin for JsExternal<'env>
impl<'env> UnwindSafe for JsExternal<'env>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<'env, T> JsValuesTuple for Twhere
T: JsValue<'env>,
impl<'env, T> JsValuesTuple for Twhere
T: JsValue<'env>,
fn env(&self) -> *mut napi_env__
Source§impl<T> JsValuesTupleIntoVec for Twhere
T: ToNapiValue,
impl<T> JsValuesTupleIntoVec for Twhere
T: ToNapiValue,
fn into_vec(self, env: *mut napi_env__) -> Result<Vec<*mut napi_value__>, Error>
Source§impl<'env, T> ToNapiValue for Twhere
T: JsValue<'env>,
impl<'env, T> ToNapiValue for Twhere
T: JsValue<'env>,
Source§unsafe fn to_napi_value(
_env: *mut napi_env__,
val: T,
) -> Result<*mut napi_value__, Error>
unsafe fn to_napi_value( _env: *mut napi_env__, val: T, ) -> Result<*mut napi_value__, Error>
Safety Read more