pub struct Object(/* private fields */);
Implementations§
Source§impl Object
impl Object
pub fn value_of(&self) -> Object
pub fn to_locale_string(&self) -> JsString
pub fn to_string(&self) -> JsString
pub fn call_self(browser: &Browser) -> JsValue
pub fn property_is_enumerable(&self, v: &dyn ToJs<JsValue>) -> JsBoolean
pub fn is_prototype_of(&self, v: &Object) -> JsBoolean
pub fn has_own_property(&self, v: &dyn ToJs<JsValue>) -> JsBoolean
pub fn keys(browser: &Browser, o: &dyn ToJs<JsObject>) -> Array<JsString>
pub fn is_extensible(browser: &Browser, o: &dyn ToJs<JsValue>) -> JsBoolean
pub fn is_frozen(browser: &Browser, o: &dyn ToJs<JsValue>) -> JsBoolean
pub fn is_sealed(browser: &Browser, o: &dyn ToJs<JsValue>) -> JsBoolean
pub fn prevent_extensions<T: JsCast>(browser: &Browser, o: &dyn ToJs<T>) -> T
pub fn freeze<T: JsCast>(browser: &Browser, o: &dyn ToJs<T>) -> T
pub fn seal<T: JsCast>(browser: &Browser, o: &dyn ToJs<T>) -> T
pub fn create(browser: &Browser, o: &dyn ToJs<JsNullable<JsObject>>) -> JsValue
pub fn get_own_property_names( browser: &Browser, o: &dyn ToJs<JsValue>, ) -> Array<JsString>
pub fn get_prototype_of_method( browser: &Browser, o: &dyn ToJs<JsValue>, ) -> JsValue
pub fn call_self_with_value( browser: &Browser, value: &dyn ToJs<JsValue>, ) -> JsValue
pub fn new(browser: &Browser, value: &dyn ToJs<JsNullable<JsValue>>) -> Object
pub fn define_properties<T: JsCast>( browser: &Browser, o: &dyn ToJs<T>, properties: &dyn ToJs<JsValue>, ) -> T
pub fn create_with_o_properties( browser: &Browser, o: &dyn ToJs<JsNullable<JsObject>>, properties: &dyn ToJs<JsValue>, ) -> JsValue
pub fn get_own_property_descriptor( browser: &Browser, o: &dyn ToJs<JsValue>, p: &dyn ToJs<JsValue>, ) -> JsNullable<PropertyDescriptor>
pub fn define_property<T: JsCast>( browser: &Browser, o: &dyn ToJs<T>, p: &dyn ToJs<JsValue>, attributes: &dyn ToJs<JsValue>, ) -> T
pub fn get_constructor(&self) -> Function
pub fn set_constructor(&self, value: &Function)
pub fn get_prototype(browser: &Browser) -> Object
pub fn set_prototype(browser: &Browser, value: &Object)
Methods from Deref<Target = JsObject>§
Sourcepub fn js_get_field(&self, property: &dyn UseInJsCode) -> JsValue
pub fn js_get_field(&self, property: &dyn UseInJsCode) -> JsValue
Get a field value of in this object.
WSDOM provides built-in getters so you should use that instead when possible.
Use js_get_field
only when needed
fn example(browser: Browser) {
// you can get `window["location"]["href"]` like this
let href: JsValue = wsdom::dom::location(&browser).js_get_field(&"href");
// but you should use built-in getters instead
let href: JsString = wsdom::dom::location(&browser).get_href();
}
Sourcepub fn js_set_field(&self, property: &dyn UseInJsCode, value: &dyn UseInJsCode)
pub fn js_set_field(&self, property: &dyn UseInJsCode, value: &dyn UseInJsCode)
Set a field value of in this object.
WSDOM provides built-in setters so you should use that instead when possible.
Use js_set_field
only when needed
fn example(browser: Browser) {
// you can set `window["location"]["href"]` like this
wsdom::dom::location(&browser).js_set_field(&"href", &"https://example.com/");
// but you should use built-in setters instead
wsdom::dom::location(&browser).set_href(&"https://example.com");
}
Sourcepub fn js_call_method<'a>(
&'a self,
method_name: &'a str,
args: impl IntoIterator<Item = &'a dyn UseInJsCode>,
last_arg_variadic: bool,
) -> JsValue
pub fn js_call_method<'a>( &'a self, method_name: &'a str, args: impl IntoIterator<Item = &'a dyn UseInJsCode>, last_arg_variadic: bool, ) -> JsValue
Call a method on this object.
Most types in WSDOM already come with safe Rust wrappers for their methods, so you should use those instead.
fn example(browser: &Browser) {
let console = wsdom::dom::console(browser);
// you can call console.log like this
console.js_call_method("log", [&"hello" as &_], false);
// but the better way is to use
wsdom::dom::console(&browser).log(&[&"Hello" as &_]);
}
Be aware that the first argument (method_name
) is NOT escaped.
Set last_arg_variadic
to true
if you want to “spread” the last argument as obj.method(arg1, arg2, ...arg3)
.
Sourcepub fn js_call_self<'a>(
&'a self,
args: impl IntoIterator<Item = &'a dyn UseInJsCode>,
last_arg_variadic: bool,
) -> JsValue
pub fn js_call_self<'a>( &'a self, args: impl IntoIterator<Item = &'a dyn UseInJsCode>, last_arg_variadic: bool, ) -> JsValue
Call this object: obj()
.
Most types in WSDOM already come with safe Rust wrappers for their methods, so you should use those instead.
Methods from Deref<Target = JsValue>§
pub fn browser(&self) -> &Browser
Sourcepub fn retrieve_json(&self) -> RetrieveFuture<'_, Value>
pub fn retrieve_json(&self) -> RetrieveFuture<'_, Value>
Retrive this value from the JS side to the Rust side. Returns Future whose output is a serde_json::Value.
§use wsdom::dom::Browser
§use wsdom::dom::HTMLInputElement;
async fn example(input: &HTMLInputElement) { let _val = input.get_value().retrieve_json().await; }