pub struct BuiltInObject {
pub name: String,
pub prototype: Option<String>,
pub methods: HashMap<String, BuiltInFn>,
pub properties: HashMap<String, JsValue>,
pub constructor: Option<BuiltInFn>,
}Expand description
Built-in object definition. Represents a JavaScript built-in object like Array, Object, String, etc.
Fields§
§name: StringName of the object (e.g., “Array”, “Object”, “Math”).
prototype: Option<String>Parent prototype name, if any (e.g., “Object” for most built-ins).
methods: HashMap<String, BuiltInFn>Methods defined on this object or its prototype.
properties: HashMap<String, JsValue>Static properties.
constructor: Option<BuiltInFn>Constructor function, if this object is constructable.
Implementations§
Source§impl BuiltInObject
impl BuiltInObject
Sourcepub fn with_prototype(self, prototype: impl Into<String>) -> Self
pub fn with_prototype(self, prototype: impl Into<String>) -> Self
Set the prototype chain parent.
Sourcepub fn with_no_prototype(self) -> Self
pub fn with_no_prototype(self) -> Self
Set no prototype (for objects like Object.prototype itself).
Sourcepub fn add_method(self, name: impl Into<String>, func: NativeFn) -> Self
pub fn add_method(self, name: impl Into<String>, func: NativeFn) -> Self
Add a native method.
Sourcepub fn add_property(self, name: impl Into<String>, value: JsValue) -> Self
pub fn add_property(self, name: impl Into<String>, value: JsValue) -> Self
Add a property.
Sourcepub fn with_constructor(self, constructor: NativeFn) -> Self
pub fn with_constructor(self, constructor: NativeFn) -> Self
Set the constructor function.
Auto Trait Implementations§
impl Freeze for BuiltInObject
impl !RefUnwindSafe for BuiltInObject
impl !Send for BuiltInObject
impl !Sync for BuiltInObject
impl Unpin for BuiltInObject
impl !UnwindSafe for BuiltInObject
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