Struct Object

Source
pub struct Object {
    pub data: ObjectData,
    /* private fields */
}
Expand description

The internal representation of an JavaScript object.

Fields§

§data: ObjectData

The type of the object.

Implementations§

Source§

impl Object

Source

pub fn new() -> Self

Source

pub fn function(function: Function, prototype: JsValue) -> Self

Return a new ObjectData struct, with kind set to Ordinary

Source

pub fn create(proto: JsValue) -> Self

ObjectCreate is used to specify the runtime creation of new ordinary objects.

More information:

Source

pub fn boolean(value: bool) -> Self

Return a new Boolean object whose [[BooleanData]] internal slot is set to argument.

Source

pub fn number(value: f64) -> Self

Return a new Number object whose [[NumberData]] internal slot is set to argument.

Source

pub fn string<S>(value: S) -> Self
where S: Into<JsString>,

Return a new String object whose [[StringData]] internal slot is set to argument.

Source

pub fn bigint(value: JsBigInt) -> Self

Return a new BigInt object whose [[BigIntData]] internal slot is set to argument.

Source

pub fn native_object<T>(value: T) -> Self
where T: NativeObject,

Create a new native object of type T.

Source

pub fn kind(&self) -> &ObjectKind

Source

pub fn is_callable(&self) -> bool

It determines if Object is a callable function with a [[Call]] internal method.

More information:

Source

pub fn is_constructable(&self) -> bool

It determines if Object is a function object with a [[Construct]] internal method.

More information:

Source

pub fn is_array(&self) -> bool

Checks if it an Array object.

Source

pub fn as_array(&self) -> Option<()>

Source

pub fn is_array_iterator(&self) -> bool

Checks if it is an ArrayIterator object.

Source

pub fn as_array_iterator(&self) -> Option<&ArrayIterator>

Source

pub fn as_array_iterator_mut(&mut self) -> Option<&mut ArrayIterator>

Source

pub fn as_string_iterator_mut(&mut self) -> Option<&mut StringIterator>

Source

pub fn as_regexp_string_iterator_mut( &mut self, ) -> Option<&mut RegExpStringIterator>

Source

pub fn as_for_in_iterator(&self) -> Option<&ForInIterator>

Source

pub fn as_for_in_iterator_mut(&mut self) -> Option<&mut ForInIterator>

Source

pub fn is_map(&self) -> bool

Checks if it is a Map object.pub

Source

pub fn as_map_ref(&self) -> Option<&OrderedMap<JsValue>>

Source

pub fn as_map_mut(&mut self) -> Option<&mut OrderedMap<JsValue>>

Source

pub fn is_map_iterator(&self) -> bool

Source

pub fn as_map_iterator_ref(&self) -> Option<&MapIterator>

Source

pub fn as_map_iterator_mut(&mut self) -> Option<&mut MapIterator>

Source

pub fn is_set(&self) -> bool

Source

pub fn as_set_ref(&self) -> Option<&OrderedSet<JsValue>>

Source

pub fn as_set_mut(&mut self) -> Option<&mut OrderedSet<JsValue>>

Source

pub fn as_set_iterator_mut(&mut self) -> Option<&mut SetIterator>

Source

pub fn is_string(&self) -> bool

Checks if it a String object.

Source

pub fn as_string(&self) -> Option<JsString>

Source

pub fn is_function(&self) -> bool

Checks if it a Function object.

Source

pub fn as_function(&self) -> Option<&Function>

Source

pub fn is_symbol(&self) -> bool

Checks if it a Symbol object.

Source

pub fn as_symbol(&self) -> Option<JsSymbol>

Source

pub fn is_error(&self) -> bool

Checks if it an Error object.

Source

pub fn as_error(&self) -> Option<()>

Source

pub fn is_boolean(&self) -> bool

Checks if it a Boolean object.

Source

pub fn as_boolean(&self) -> Option<bool>

Source

pub fn is_number(&self) -> bool

Checks if it a Number object.

Source

pub fn as_number(&self) -> Option<f64>

Source

pub fn is_bigint(&self) -> bool

Checks if it a BigInt object.

Source

pub fn as_bigint(&self) -> Option<&JsBigInt>

Source

pub fn is_date(&self) -> bool

Source

pub fn as_date(&self) -> Option<&Date>

Source

pub fn is_regexp(&self) -> bool

Checks if it a RegExp object.

Source

pub fn as_regexp(&self) -> Option<&RegExp>

Source

pub fn is_ordinary(&self) -> bool

Checks if it an ordinary object.

Source

pub fn prototype_instance(&self) -> &JsValue

Source

pub fn set_prototype_instance(&mut self, prototype: JsValue) -> bool

Sets the prototype instance of the object.

More information

Source

pub fn with_prototype(proto: JsValue, data: ObjectData) -> Object

Similar to Value::new_object, but you can pass a prototype to create from, plus a kind

Source

pub fn is_native_object(&self) -> bool

Returns true if it holds an Rust type that implements NativeObject.

Source

pub fn as_native_object(&self) -> Option<&dyn NativeObject>

Source

pub fn is<T>(&self) -> bool
where T: NativeObject,

Reeturn true if it is a native object and the native type is T.

Source

pub fn downcast_ref<T>(&self) -> Option<&T>
where T: NativeObject,

Downcast a reference to the object, if the object is type native object type T.

Source

pub fn downcast_mut<T>(&mut self) -> Option<&mut T>
where T: NativeObject,

Downcast a mutable reference to the object, if the object is type native object type T.

Source

pub fn properties(&self) -> &PropertyMap

Source

pub fn insert_property<K, P>( &mut self, key: K, property: P, ) -> Option<PropertyDescriptor>

Inserts a field in the object properties without checking if it’s writable.

If a field was already in the object with the same name that a Some is returned with that field, otherwise None is retuned.

Trait Implementations§

Source§

impl Debug for Object

Source§

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

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

impl Default for Object

Source§

fn default() -> Self

Return a new ObjectData struct, with kind set to Ordinary

Source§

impl Drop for Object

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Finalize for Object

Source§

impl From<Object> for JsValue

Source§

fn from(object: Object) -> Self

Converts to this type from the input type.
Source§

impl Trace for Object

Source§

unsafe fn trace(&self)

Marks all contained Gcs.
Source§

unsafe fn root(&self)

Increments the root-count of all contained Gcs.
Source§

unsafe fn unroot(&self)

Decrements the root-count of all contained Gcs.
Source§

fn finalize_glue(&self)

Runs Finalize::finalize() on this object and all contained subobjects

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> 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> NativeObject for T
where T: Any + Debug + Trace,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert the Rust type which implements NativeObject to a &dyn Any.
Source§

fn as_mut_any(&mut self) -> &mut (dyn Any + 'static)

Convert the Rust type which implements NativeObject to a &mut dyn Any.
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V