Struct napi::JsObject

source ·
pub struct JsObject(/* private fields */);

Implementations§

source§

impl JsObject

source

pub fn get<K: AsRef<str>, V: FromNapiValue>( &self, field: K ) -> Result<Option<V>>

source

pub fn set<K: AsRef<str>, V: ToNapiValue>( &mut self, field: K, val: V ) -> Result<()>

source

pub fn keys(obj: &Object) -> Result<Vec<String>>

source§

impl JsObject

source

pub 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,

source§

impl JsObject

source

pub fn into_unknown(self) -> JsUnknown

source

pub fn coerce_to_bool(self) -> Result<JsBoolean>

source

pub fn coerce_to_number(self) -> Result<JsNumber>

source

pub fn coerce_to_string(self) -> Result<JsString>

source

pub fn coerce_to_object(self) -> Result<JsObject>

source

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

source

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

source

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

source

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

source

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

source

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

source

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

source

pub fn instanceof<Constructor>(&self, constructor: Constructor) -> Result<bool>
where Constructor: NapiRaw,

source§

impl JsObject

source

pub fn set_property<K, V>(&mut self, key: K, value: V) -> Result<()>
where K: NapiRaw, V: NapiRaw,

source

pub fn get_property<K, T>(&self, key: K) -> Result<T>
where K: NapiRaw, T: NapiValue,

source

pub fn get_property_unchecked<K, T>(&self, key: K) -> Result<T>
where K: NapiRaw, T: NapiValue,

source

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

source

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

source

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

source

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

source

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

source

pub fn delete_property<S>(&mut self, name: S) -> Result<bool>
where S: NapiRaw,

source

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

source

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

source

pub fn has_own_property_js<K>(&self, key: K) -> Result<bool>
where K: NapiRaw,

source

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

source

pub fn has_property_js<K>(&self, name: K) -> Result<bool>
where K: NapiRaw,

source

pub fn get_property_names(&self) -> Result<JsObject>

source

pub fn get_all_property_names( &self, mode: KeyCollectionMode, filter: KeyFilter, conversion: KeyConversion ) -> Result<JsObject>

source

pub fn get_prototype<T>(&self) -> Result<T>
where T: NapiValue,

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

source

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

source

pub fn set_element<T>(&mut self, index: u32, value: T) -> Result<()>
where T: NapiRaw,

source

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

source

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

source

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

source

pub fn get_element_unchecked<T>(&self, index: u32) -> Result<T>
where T: NapiValue,

source

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

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

source

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

Perform is_array check before get the length if Object is not array, ArrayExpected error returned

source

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

use this API if you can ensure this Object is Array

source

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

source

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

Trait Implementations§

source§

impl<'env> NapiRaw for &'env JsObject

source§

unsafe fn raw(&self) -> napi_value

source§

impl NapiRaw for JsObject

source§

unsafe fn raw(&self) -> napi_value

source§

impl NapiValue for JsObject

source§

impl TryFrom<JsUnknown> for JsObject

§

type Error = Error

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

fn try_from(value: JsUnknown) -> Result<JsObject>

Performs the conversion.
source§

impl ValidateNapiValue for JsObject

source§

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

Safety Read more

Auto Trait Implementations§

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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FromNapiValue for T
where T: NapiValue,

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<T> JsValuesTupleIntoVec for T
where T: ToNapiValue,

source§

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

source§

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

§

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>,

§

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.