pub struct JsObject(/* private fields */);
Expand description
Pointer type for Js allocated object Consider this as a Box, but pointing into JS memory -1 is nil
Implementations§
Source§impl JsObject
impl JsObject
Sourcepub fn weak(&self) -> JsObjectWeak
pub fn weak(&self) -> JsObjectWeak
Get a weak reference to js memory No guarantees against js garbage collector
Source§impl JsObject
impl JsObject
pub const NULL: Self
pub const UNDEFINED: Self
Sourcepub fn object() -> JsObject
pub fn object() -> JsObject
Allocate new javascript object with object type. Like “var object = {}” in JS.
Sourcepub fn to_string(&self, buf: &mut String)
pub fn to_string(&self, buf: &mut String)
Read JS object content to a given string Will panic if object is not a string Will not allocate memory if string is large enough, will use “String::reserve” otherwise
Sourcepub fn to_byte_buffer(&self, buf: &mut Vec<u8>)
pub fn to_byte_buffer(&self, buf: &mut Vec<u8>)
Read JS object content to a given bytes buffer Will panic if object is not a buffer Will use .resize() on “buf”, so if “buf” is large enough - no memory is going to be allocated here
Sourcepub fn field(&self, field: &str) -> JsObject
pub fn field(&self, field: &str) -> JsObject
Get a new JsObject from this object .field Will panic if self is not an object or map
Sourcepub fn field_u32(&self, field: &str) -> u32
pub fn field_u32(&self, field: &str) -> u32
Get a value from this object .field Will panic if self is not an object or map
Sourcepub fn have_field(&self, field: &str) -> bool
pub fn have_field(&self, field: &str) -> bool
.field == undefined
Sourcepub fn field_f32(&self, field: &str) -> f32
pub fn field_f32(&self, field: &str) -> f32
Get a value from this object .field Will panic if self is not an object or map
Sourcepub fn set_field_f32(&self, field: &str, data: f32)
pub fn set_field_f32(&self, field: &str, data: f32)
Set .field or [“field”] to given f32, like “object.field = data”; Will panic if self is not an object or map
Sourcepub fn set_field_u32(&self, field: &str, data: u32)
pub fn set_field_u32(&self, field: &str, data: u32)
Set .field or [“field”] to given u32, like “object.field = data”; Will panic if self is not an object or map
Sourcepub fn set_field_string(&self, field: &str, data: &str)
pub fn set_field_string(&self, field: &str, data: &str)
Set .field or [“field”] to given string, like “object.field = data”; Will panic if self is not an object or map
Sourcepub fn is_undefined(&self) -> bool
pub fn is_undefined(&self) -> bool
Checks whether the JsObject handle is undefined