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
sourceimpl Object
impl Object
pub fn new() -> Self
sourcepub fn function(function: Function, prototype: JsValue) -> Self
pub fn function(function: Function, prototype: JsValue) -> Self
Return a new ObjectData struct, with kind
set to Ordinary
sourcepub fn create(proto: JsValue) -> Self
pub fn create(proto: JsValue) -> Self
ObjectCreate is used to specify the runtime creation of new ordinary objects.
More information:
sourcepub fn boolean(value: bool) -> Self
pub fn boolean(value: bool) -> Self
Return a new Boolean object whose [[BooleanData]]
internal slot is set to argument.
sourcepub fn number(value: f64) -> Self
pub fn number(value: f64) -> Self
Return a new Number
object whose [[NumberData]]
internal slot is set to argument.
sourcepub fn string<S>(value: S) -> Selfwhere
S: Into<JsString>,
pub fn string<S>(value: S) -> Selfwhere
S: Into<JsString>,
Return a new String
object whose [[StringData]]
internal slot is set to argument.
sourcepub fn bigint(value: JsBigInt) -> Self
pub fn bigint(value: JsBigInt) -> Self
Return a new BigInt
object whose [[BigIntData]]
internal slot is set to argument.
sourcepub fn native_object<T>(value: T) -> Selfwhere
T: NativeObject,
pub fn native_object<T>(value: T) -> Selfwhere
T: NativeObject,
Create a new native object of type T
.
pub fn kind(&self) -> &ObjectKind
sourcepub fn is_callable(&self) -> bool
pub fn is_callable(&self) -> bool
It determines if Object is a callable function with a [[Call]]
internal method.
More information:
sourcepub fn is_constructable(&self) -> bool
pub fn is_constructable(&self) -> bool
It determines if Object is a function object with a [[Construct]]
internal method.
More information:
pub fn as_array(&self) -> Option<()>
sourcepub fn is_array_iterator(&self) -> bool
pub fn is_array_iterator(&self) -> bool
Checks if it is an ArrayIterator
object.
pub fn as_array_iterator(&self) -> Option<&ArrayIterator>
pub fn as_array_iterator_mut(&mut self) -> Option<&mut ArrayIterator>
pub fn as_string_iterator_mut(&mut self) -> Option<&mut StringIterator>
pub fn as_regexp_string_iterator_mut(
&mut self
) -> Option<&mut RegExpStringIterator>
pub fn as_for_in_iterator(&self) -> Option<&ForInIterator>
pub fn as_for_in_iterator_mut(&mut self) -> Option<&mut ForInIterator>
pub fn as_map_ref(&self) -> Option<&OrderedMap<JsValue>>
pub fn as_map_mut(&mut self) -> Option<&mut OrderedMap<JsValue>>
pub fn is_map_iterator(&self) -> bool
pub fn as_map_iterator_ref(&self) -> Option<&MapIterator>
pub fn as_map_iterator_mut(&mut self) -> Option<&mut MapIterator>
pub fn is_set(&self) -> bool
pub fn as_set_ref(&self) -> Option<&OrderedSet<JsValue>>
pub fn as_set_mut(&mut self) -> Option<&mut OrderedSet<JsValue>>
pub fn as_set_iterator_mut(&mut self) -> Option<&mut SetIterator>
pub fn as_string(&self) -> Option<JsString>
sourcepub fn is_function(&self) -> bool
pub fn is_function(&self) -> bool
Checks if it a Function
object.
pub fn as_function(&self) -> Option<&Function>
pub fn as_symbol(&self) -> Option<JsSymbol>
pub fn as_error(&self) -> Option<()>
sourcepub fn is_boolean(&self) -> bool
pub fn is_boolean(&self) -> bool
Checks if it a Boolean object.
pub fn as_boolean(&self) -> Option<bool>
pub fn as_number(&self) -> Option<f64>
pub fn as_bigint(&self) -> Option<&JsBigInt>
pub fn is_date(&self) -> bool
pub fn as_date(&self) -> Option<&Date>
pub fn as_regexp(&self) -> Option<&RegExp>
sourcepub fn is_ordinary(&self) -> bool
pub fn is_ordinary(&self) -> bool
Checks if it an ordinary object.
pub fn prototype_instance(&self) -> &JsValue
sourcepub fn set_prototype_instance(&mut self, prototype: JsValue) -> bool
pub fn set_prototype_instance(&mut self, prototype: JsValue) -> bool
Sets the prototype instance of the object.
sourcepub fn with_prototype(proto: JsValue, data: ObjectData) -> Object
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
sourcepub fn is_native_object(&self) -> bool
pub fn is_native_object(&self) -> bool
Returns true
if it holds an Rust type that implements NativeObject
.
pub fn as_native_object(&self) -> Option<&dyn NativeObject>
sourcepub fn is<T>(&self) -> boolwhere
T: NativeObject,
pub fn is<T>(&self) -> boolwhere
T: NativeObject,
Reeturn true
if it is a native object and the native type is T
.
sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: NativeObject,
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
.
sourcepub fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: NativeObject,
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
.
pub fn properties(&self) -> &PropertyMap
sourcepub fn insert_property<K, P>(
&mut self,
key: K,
property: P
) -> Option<PropertyDescriptor>where
K: Into<PropertyKey>,
P: Into<PropertyDescriptor>,
pub fn insert_property<K, P>(
&mut self,
key: K,
property: P
) -> Option<PropertyDescriptor>where
K: Into<PropertyKey>,
P: Into<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.