Trait neon::object::Object

source ·
pub trait Object: Value {
    // Provided methods
    fn get_opt<'a, V: Value, C: Context<'a>, K: PropertyKey>(
        &self,
        cx: &mut C,
        key: K
    ) -> NeonResult<Option<Handle<'a, V>>> { ... }
    fn get_value<'a, C: Context<'a>, K: PropertyKey>(
        &self,
        cx: &mut C,
        key: K
    ) -> NeonResult<Handle<'a, JsValue>> { ... }
    fn get<'a, V: Value, C: Context<'a>, K: PropertyKey>(
        &self,
        cx: &mut C,
        key: K
    ) -> NeonResult<Handle<'a, V>> { ... }
    fn get_own_property_names<'a, C: Context<'a>>(
        &self,
        cx: &mut C
    ) -> JsResult<'a, JsArray> { ... }
    fn freeze<'a, C: Context<'a>>(&self, cx: &mut C) -> NeonResult<&Self> { ... }
    fn seal<'a, C: Context<'a>>(&self, cx: &mut C) -> NeonResult<&Self> { ... }
    fn set<'a, C: Context<'a>, K: PropertyKey, W: Value>(
        &self,
        cx: &mut C,
        key: K,
        val: Handle<'_, W>
    ) -> NeonResult<bool> { ... }
    fn root<'a, C: Context<'a>>(&self, cx: &mut C) -> Root<Self> { ... }
    fn call_method_with<'a, C, K>(
        &self,
        cx: &mut C,
        method: K
    ) -> NeonResult<CallOptions<'a>>
       where C: Context<'a>,
             K: PropertyKey { ... }
}
Expand description

The trait of all object types.

Provided Methods§

source

fn get_opt<'a, V: Value, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K ) -> NeonResult<Option<Handle<'a, V>>>

Gets a property from a JavaScript object that may be undefined and attempts to downcast the value if it existed.

source

fn get_value<'a, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K ) -> NeonResult<Handle<'a, JsValue>>

Gets a property from a JavaScript object as a JsValue.

If a getter is defined on the object, it will be called.

source

fn get<'a, V: Value, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K ) -> NeonResult<Handle<'a, V>>

Gets a property from a JavaScript object and attempts to downcast as a specific type. Equivalent to calling obj.get_value(&mut cx)?.downcast_or_throw(&mut cx).

Throws an exception if the value is a different type.

source

fn get_own_property_names<'a, C: Context<'a>>( &self, cx: &mut C ) -> JsResult<'a, JsArray>

Available on crate feature napi-6 only.
source

fn freeze<'a, C: Context<'a>>(&self, cx: &mut C) -> NeonResult<&Self>

source

fn seal<'a, C: Context<'a>>(&self, cx: &mut C) -> NeonResult<&Self>

source

fn set<'a, C: Context<'a>, K: PropertyKey, W: Value>( &self, cx: &mut C, key: K, val: Handle<'_, W> ) -> NeonResult<bool>

source

fn root<'a, C: Context<'a>>(&self, cx: &mut C) -> Root<Self>

source

fn call_method_with<'a, C, K>( &self, cx: &mut C, method: K ) -> NeonResult<CallOptions<'a>>
where C: Context<'a>, K: PropertyKey,

Object Safety§

This trait is not object safe.

Implementors§