Struct Object

Source
pub struct Object { /* private fields */ }

Implementations§

Source§

impl Object

Source

pub fn get<K: ToValue, V: FromValue>(&self, key: K) -> Result<V>

Get an object property value using the given key. Returns Value::Undefined if no property with the key exists.

Returns an error if ToValue::to_value fails for the key or if the key value could not be cast to a property key string.

Source

pub fn set<K: ToValue, V: ToValue>(&self, key: K, value: V) -> Result<()>

Sets an object property using the given key and value.

Returns an error if ToValue::to_value fails for either the key or the value or if the key value could not be cast to a property key string.

Source

pub fn remove<K: ToValue>(&self, key: K) -> Result<()>

Removes the property associated with the given key from the object. This function does nothing if the property does not exist.

Returns an error if ToValue::to_value fails for the key or if the key value could not be cast to a property key string.

Source

pub fn has<K: ToValue>(&self, key: K) -> Result<bool>

Returns true if the given key is a property of the object, false otherwise.

Returns an error if ToValue::to_value fails for the key or if the key value could not be cast to a property key string.

Source

pub fn call_prop<K, A, R>(&self, key: K, args: A) -> Result<R>
where K: ToValue, A: ToValues, R: FromValue,

Calls the function at the key with the given arguments, with this set to the object. Returns an error if the value at the key is not a function.

Source

pub fn keys(&self, include_inherited: bool) -> Result<Array>

Returns an array containing all of this object’s enumerable property keys. If include_inherited is false, then only the object’s own enumerable properties will be collected (similar to Object.getOwnPropertyNames in Javascript). If include_inherited is true, then the object’s own properties and the enumerable properties from its prototype chain will be collected.

Source

pub fn properties<K, V>( self, include_inherited: bool, ) -> Result<Properties<K, V>>
where K: FromValue, V: FromValue,

Converts the object into an iterator over the object’s keys and values, acting like a for-in loop.

For information on the include_inherited argument, see Object::keys.

Trait Implementations§

Source§

impl Clone for Object

Source§

fn clone(&self) -> Object

Returns a copy 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 Debug for Object

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FromValue for Object

Source§

fn from_value(value: Value, _mv8: &MiniV8) -> Result<Object>

Performs the conversion.
Source§

impl ToValue for Object

Source§

fn to_value(self, _mv8: &MiniV8) -> Result<Value>

Performs the conversion.

Auto Trait Implementations§

§

impl Freeze for Object

§

impl !RefUnwindSafe for Object

§

impl !Send for Object

§

impl !Sync for Object

§

impl Unpin for Object

§

impl !UnwindSafe for Object

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