ClassInstance

Struct ClassInstance 

Source
pub struct ClassInstance<'env, T: 'env> {
    pub value: napi_value,
    /* private fields */
}

Fields§

§value: napi_value

Implementations§

Source§

impl<'env, T: 'env> ClassInstance<'env, T>

Source

pub fn as_object<'a>(&self, env: &'a Env) -> Object<'a>

Source

pub fn assign_to_this<'a, 'this, U>( &'a self, name: &'a str, this: &'a mut This<'_, U>, ) -> Result<ClassInstance<'this, T>>
where U: FromNapiValue + JsValue<'this>, 'this: 'env,

Assign this ClassInstance to another This object

Extends the lifetime of ClassInstance to This.

Source

pub fn assign_to_this_with_attributes<'a, 'this, U>( &'a self, name: &'a str, attributes: PropertyAttributes, this: &'a mut This<'_, U>, ) -> Result<ClassInstance<'this, T>>
where U: FromNapiValue + JsValue<'this>, 'this: 'env,

Assign this ClassInstance to another This object with PropertyAttributes.

Extends the lifetime of ClassInsatnce to This.

Trait Implementations§

Source§

impl<'env, T: 'env> AsRef<T> for ClassInstance<'env, T>

Source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<'env, T: Clone + 'env> Clone for ClassInstance<'env, T>

Source§

fn clone(&self) -> ClassInstance<'env, T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'env, T: 'env> Deref for ClassInstance<'env, T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'env, T: 'env> DerefMut for ClassInstance<'env, T>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<'env, T: 'env> FromNapiValue for ClassInstance<'env, T>

Source§

unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>

Safety Read more
Source§

fn from_unknown(value: Unknown<'_>) -> Result<Self>

Source§

impl<'env, T: 'env> JsObjectValue<'env> for ClassInstance<'env, T>

Source§

fn set_property<'k, 'v, K, V>(&mut self, key: K, value: V) -> Result<()>
where K: JsValue<'k>, V: JsValue<'v>,

Set the property value to the Object
Source§

fn get_property<'k, K, T>(&self, key: K) -> Result<T>

Get the property value from the Object Read more
Source§

fn get_property_unchecked<'k, K, T>(&self, key: K) -> Result<T>
where K: JsValue<'k>, T: FromNapiValue,

Get the property value from the Object without validation
Source§

fn set_named_property<T>(&mut self, name: &str, value: T) -> Result<()>
where T: ToNapiValue,

Set the property value to the Object
Source§

fn set_c_named_property<T>(&mut self, name: &CStr, value: T) -> Result<()>
where T: ToNapiValue,

Set the property value to the Object, the property name is a CStr This is useful when the property name comes from a C library
Source§

fn create_named_method<K>(&mut self, name: K, function: Callback) -> Result<()>
where K: AsRef<str>,

Create a named method on the Object
Source§

fn create_c_named_method( &mut self, name: &CStr, function: Callback, ) -> Result<()>

Create a named method on the Object, the name is a CStr This is useful when the method name comes from a C library
Source§

fn get_named_property<T>(&self, name: &str) -> Result<T>

Get the property value from the Object Read more
Source§

fn get_c_named_property<T>(&self, name: &CStr) -> Result<T>

Get the property value from the Object Read more
Source§

fn get_named_property_unchecked<T>(&self, name: &str) -> Result<T>
where T: FromNapiValue,

Get the property value from the Object without validation
Source§

fn get_c_named_property_unchecked<T>(&self, name: &CStr) -> Result<T>
where T: FromNapiValue,

Get the property value from the Object without validation Read more
Source§

fn has_named_property<N: AsRef<str>>(&self, name: N) -> Result<bool>

Check if the Object has the named property
Source§

fn has_c_named_property(&self, name: &CStr) -> Result<bool>

Check if the Object has the named property Read more
Source§

fn delete_property<'s, S>(&mut self, name: S) -> Result<bool>
where S: JsValue<'s>,

Delete the property from the Object, the property name can be a JsValue
Source§

fn delete_named_property<K: AsRef<str>>(&mut self, name: K) -> Result<bool>

Delete the property from the Object
Source§

fn delete_c_named_property(&mut self, name: &CStr) -> Result<bool>

Delete the property from the Object Read more
Source§

fn has_own_property(&self, key: &str) -> Result<bool>

Check if the Object has the own property
Source§

fn has_c_own_property(&self, key: &CStr) -> Result<bool>

Check if the Object has the own property Read more
Source§

fn has_own_property_js<'k, K>(&self, key: K) -> Result<bool>
where K: JsValue<'k>,

The same as has_own_property, but accepts a JsValue as the property name.
Source§

fn has_property(&self, name: &str) -> Result<bool>

This API checks if the Object passed in has the named property.
Source§

fn has_property_js<'k, K>(&self, name: K) -> Result<bool>
where K: JsValue<'k>,

This API is the same as has_property, but accepts a JsValue as the property name. So you can pass the JsNumber or JsSymbol as the property name.
Source§

fn get_property_names(&self) -> Result<Object<'env>>

This API returns the names of the enumerable properties of object as an array of strings. The properties of object whose key is a symbol will not be included.
Source§

fn get_all_property_names( &self, mode: KeyCollectionMode, filter: KeyFilter, conversion: KeyConversion, ) -> Result<Object<'env>>

https://nodejs.org/api/n-api.html#n_api_napi_get_all_property_names This API returns an array containing the names of the available properties of this object.
Source§

fn get_prototype(&self) -> Result<Unknown<'env>>

This returns the equivalent of Object.getPrototypeOf (which is not the same as the function’s prototype property).
Source§

fn get_prototype_unchecked<T>(&self) -> Result<T>
where T: FromNapiValue,

Get the prototype of the Object
Source§

fn set_element<'t, T>(&mut self, index: u32, value: T) -> Result<()>
where T: JsValue<'t>,

Set the element at the given index
Source§

fn has_element(&self, index: u32) -> Result<bool>

Check if the Array has the element at the given index
Source§

fn delete_element(&mut self, index: u32) -> Result<bool>

Delete the element at the given index
Source§

fn get_element<T>(&self, index: u32) -> Result<T>
where T: FromNapiValue,

Get the element at the given index Read more
Source§

fn define_properties(&mut self, properties: &[Property]) -> Result<()>

This method allows the efficient definition of multiple properties on a given object.
Source§

fn get_array_length(&self) -> Result<u32>

Perform is_array check before get the length Read more
Source§

fn get_array_length_unchecked(&self) -> Result<u32>

use this API if you can ensure this Object is Array
Source§

fn wrap<T: 'static>( &mut self, native_object: T, size_hint: Option<usize>, ) -> Result<()>

Wrap the native value T to this Object the T will be dropped when this Object is finalized
Source§

fn unwrap<T: 'static>(&self) -> Result<&mut T>

Get the wrapped native value from the Object Read more
Source§

fn remove_wrapped<T: 'static>(&mut self) -> Result<()>

Remove the wrapped native value from the Object Read more
Source§

fn add_finalizer<T, Hint, F>( &mut self, native: T, finalize_hint: Hint, finalize_cb: F, ) -> Result<()>
where T: 'static, Hint: 'static, F: FnOnce(FinalizeContext<T, Hint>) + 'static,

Adds a finalize_cb callback which will be called when the JavaScript object in js_object has been garbage-collected. Read more
Source§

fn freeze(&mut self) -> Result<()>

This method freezes a given object. This prevents new properties from being added to it, existing properties from being removed, prevents changing the enumerability, configurability, or writability of existing properties, and prevents the values of existing properties from being changed. It also prevents the object’s prototype from being changed. This is described in Section 19.1.2.6 of the ECMA-262 specification.
Source§

fn seal(&mut self) -> Result<()>

This method seals a given object. This prevents new properties from being added to it, as well as marking all existing properties as non-configurable. This is described in Section 19.1.2.20 of the ECMA-262 specification.
Source§

impl<'env, T: 'env> JsValue<'env> for ClassInstance<'env, T>

Source§

fn value(&self) -> Value

Source§

fn raw(&self) -> napi_value

Source§

fn to_unknown(&self) -> Unknown<'env>

Convert the value to an unknown
Source§

fn coerce_to_bool(&self) -> Result<bool>

Coerce the value to a boolean
Source§

fn coerce_to_number(&self) -> Result<JsNumber<'_>>

Source§

fn coerce_to_string(&self) -> Result<JsString<'_>>

Source§

fn coerce_to_object(&self) -> Result<Object<'env>>

Source§

fn is_date(&self) -> Result<bool>

Source§

fn is_promise(&self) -> Result<bool>

Source§

fn is_error(&self) -> Result<bool>

Source§

fn is_typedarray(&self) -> Result<bool>

Source§

fn is_dataview(&self) -> Result<bool>

Source§

fn is_array(&self) -> Result<bool>

Source§

fn is_buffer(&self) -> Result<bool>

Source§

fn is_arraybuffer(&self) -> Result<bool>

Source§

fn instanceof<'c, Constructor>(&self, constructor: Constructor) -> Result<bool>
where Constructor: JsValue<'c>,

Source§

fn escape<'scope, E: JsValue<'scope> + FromNapiValue>( &self, escapable_handle_scope: EscapableHandleScope<'scope>, ) -> Result<E>

Source§

impl<'env, T: 'env> TypeName for ClassInstance<'env, T>

Source§

impl<'env, T: 'env> ValidateNapiValue for ClassInstance<'env, T>

Source§

unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>

Safety Read more
Source§

impl<'env, T: Copy + 'env> Copy for ClassInstance<'env, T>

Auto Trait Implementations§

§

impl<'env, T> Freeze for ClassInstance<'env, T>

§

impl<'env, T> RefUnwindSafe for ClassInstance<'env, T>
where T: RefUnwindSafe,

§

impl<'env, T> !Send for ClassInstance<'env, T>

§

impl<'env, T> !Sync for ClassInstance<'env, T>

§

impl<'env, T> Unpin for ClassInstance<'env, T>

§

impl<'env, T> UnwindSafe for ClassInstance<'env, T>
where T: RefUnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<'env, T> JsValuesTuple for T
where T: JsValue<'env>,

Source§

impl<T> JsValuesTupleIntoVec for T
where T: ToNapiValue,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<'env, T> ToNapiValue for T
where T: JsValue<'env>,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.