pub struct WindowOrWorkerGlobalScope(/* private fields */);
Implementations§
Source§impl WindowOrWorkerGlobalScope
impl WindowOrWorkerGlobalScope
pub fn report_error(&self, e: &dyn ToJs<JsValue>) -> JsNullish
pub fn queue_microtask(&self, callback: &dyn ToJs<VoidFunction>) -> JsNullish
pub fn clear_timeout(&self, id: &dyn ToJs<JsNullable<JsNumber>>) -> JsNullish
pub fn clear_interval(&self, id: &dyn ToJs<JsNullable<JsNumber>>) -> JsNullish
pub fn btoa(&self, data: &dyn ToJs<JsString>) -> JsString
pub fn atob(&self, data: &dyn ToJs<JsString>) -> JsString
pub fn structured_clone<T: JsCast>( &self, value: &dyn ToJs<T>, options: &dyn ToJs<JsNullable<StructuredSerializeOptions>>, ) -> T
pub fn fetch( &self, input: &dyn ToJs<JsValue>, init: &dyn ToJs<JsNullable<RequestInit>>, ) -> Promise<Response>
pub fn create_image_bitmap( &self, image: &dyn ToJs<JsValue>, options: &dyn ToJs<JsNullable<ImageBitmapOptions>>, ) -> Promise<ImageBitmap>
pub fn set_timeout( &self, handler: &dyn ToJs<JsValue>, timeout: &dyn ToJs<JsNullable<JsNumber>>, arguments: &dyn ToJs<Array<JsValue>>, ) -> JsNumber
pub fn set_interval( &self, handler: &dyn ToJs<JsValue>, timeout: &dyn ToJs<JsNullable<JsNumber>>, arguments: &dyn ToJs<Array<JsValue>>, ) -> JsNumber
pub fn create_image_bitmap_with_image_sx_sy_sw_sh_options( &self, image: &dyn ToJs<JsValue>, sx: &dyn ToJs<JsNumber>, sy: &dyn ToJs<JsNumber>, sw: &dyn ToJs<JsNumber>, sh: &dyn ToJs<JsNumber>, options: &dyn ToJs<JsNullable<ImageBitmapOptions>>, ) -> Promise<ImageBitmap>
pub fn get_performance(&self) -> Performance
pub fn set_performance(&self, value: &Performance)
pub fn get_origin(&self) -> JsString
pub fn set_origin(&self, value: &dyn ToJs<JsString>)
pub fn get_is_secure_context(&self) -> JsBoolean
pub fn set_is_secure_context(&self, value: &dyn ToJs<JsBoolean>)
pub fn get_indexed_db(&self) -> IDBFactory
pub fn set_indexed_db(&self, value: &IDBFactory)
pub fn get_crypto(&self) -> Crypto
pub fn set_crypto(&self, value: &Crypto)
pub fn get_cross_origin_isolated(&self) -> JsBoolean
pub fn set_cross_origin_isolated(&self, value: &dyn ToJs<JsBoolean>)
pub fn get_caches(&self) -> CacheStorage
pub fn set_caches(&self, value: &CacheStorage)
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; }
Trait Implementations§
Source§impl AsRef<JsObject> for WindowOrWorkerGlobalScope
impl AsRef<JsObject> for WindowOrWorkerGlobalScope
Source§impl AsRef<JsValue> for WindowOrWorkerGlobalScope
impl AsRef<JsValue> for WindowOrWorkerGlobalScope
Source§impl AsRef<WindowOrWorkerGlobalScope> for Window
impl AsRef<WindowOrWorkerGlobalScope> for Window
Source§fn as_ref(&self) -> &WindowOrWorkerGlobalScope
fn as_ref(&self) -> &WindowOrWorkerGlobalScope
Source§impl Clone for WindowOrWorkerGlobalScope
impl Clone for WindowOrWorkerGlobalScope
Source§fn clone(&self) -> WindowOrWorkerGlobalScope
fn clone(&self) -> WindowOrWorkerGlobalScope
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more