pub struct JsObject(/* private fields */);Expand description
The type of JavaScript objects, i.e., the root of all object types.
§Example
// Create an object:
let obj = cx.empty_object()
.prop(&mut cx, "name")
.set("Neon")?
.prop("url")
.set("https://neon-bindings.com")?
.this();
// Call console.log(obj):
cx.global::<JsObject>("console")?.method(&mut cx, "log")?.arg(obj)?.exec()?;Implementations§
Trait Implementations§
Source§impl Object for JsObject
impl Object for JsObject
Source§fn 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. Read moreSource§fn 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. Read moreSource§fn get_opt<'a, V: Value, C: Context<'a>, K: PropertyKey>(
&self,
cx: &mut C,
key: K,
) -> NeonResult<Option<Handle<'a, V>>>
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() insteadSource§fn get_value<'a, C: Context<'a>, K: PropertyKey>(
&self,
cx: &mut C,
key: K,
) -> NeonResult<Handle<'a, JsValue>>
fn 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() insteadSource§fn get<'a, V: Value, C: Context<'a>, K: PropertyKey>(
&self,
cx: &mut C,
key: K,
) -> NeonResult<Handle<'a, V>>
fn 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() insteadSource§fn get_own_property_names<'a, C: Context<'a>>(
&self,
cx: &mut C,
) -> JsResult<'a, JsArray>
fn 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>
Source§fn set<'a, C: Context<'a>, K: PropertyKey, W: Value>(
&self,
cx: &mut C,
key: K,
val: Handle<'_, W>,
) -> NeonResult<bool>
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>
Source§fn call_method_with<'a, C, K>(
&self,
cx: &mut C,
method: K,
) -> NeonResult<CallOptions<'a>>where
C: Context<'a>,
K: PropertyKey,
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() insteadSource§impl Value for JsObject
impl Value for JsObject
Auto Trait Implementations§
impl Freeze for JsObject
impl RefUnwindSafe for JsObject
impl !Send for JsObject
impl !Sync for JsObject
impl Unpin for JsObject
impl UnwindSafe for JsObject
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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more