pub trait Object: Value {
// Provided methods
fn prop<'a, 'cx: 'a, K: PropertyKey>(
&self,
cx: &'a mut Cx<'cx>,
key: K,
) -> PropOptions<'a, 'cx, Self, K> { ... }
fn method<'a, 'cx: 'a, K: PropertyKey>(
&self,
cx: &'a mut Cx<'cx>,
key: K,
) -> NeonResult<BindOptions<'a, 'cx>> { ... }
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§
Sourcefn prop<'a, 'cx: 'a, K: PropertyKey>(
&self,
cx: &'a mut Cx<'cx>,
key: K,
) -> PropOptions<'a, 'cx, Self, K>
fn prop<'a, 'cx: 'a, K: PropertyKey>( &self, cx: &'a mut Cx<'cx>, key: K, ) -> PropOptions<'a, 'cx, Self, K>
Create a PropOptions
for accessing a property.
§Safety
Because cx
is a mutable reference, Neon guarantees it
is the context with the shortest possible lifetime, so
replacing the lifetime 'self
with 'cx
cannot extend
the lifetime of the property beyond the lifetime of the
object.
Sourcefn method<'a, 'cx: 'a, K: PropertyKey>(
&self,
cx: &'a mut Cx<'cx>,
key: K,
) -> NeonResult<BindOptions<'a, 'cx>>
fn method<'a, 'cx: 'a, K: PropertyKey>( &self, cx: &'a mut Cx<'cx>, key: K, ) -> NeonResult<BindOptions<'a, 'cx>>
Gets a property from the object as a method and binds this
to the object.
May throw an exception either from accessing the property.
Defers checking that the method is callable until call time.
fn get_opt<'a, V: Value, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Option<Handle<'a, V>>>
👎Deprecating in a future version: use
Object::prop()
insteadfn get_value<'a, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Handle<'a, JsValue>>
👎Deprecating in a future version: use
Object::prop()
insteadfn get<'a, V: Value, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Handle<'a, V>>
👎Deprecating in a future version: use
Object::prop()
insteadfn get_own_property_names<'a, C: Context<'a>>( &self, cx: &mut C, ) -> JsResult<'a, JsArray>
Available on crate feature
napi-6
only.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>
👎Deprecating in a future version: use
Object::prop()
insteadfn 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,
👎Deprecating in a future version: use
Object::method()
insteadDyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.