web_sys/
lib.rs

1//! Raw API bindings for Web APIs
2//!
3//! This is a procedurally generated crate from browser WebIDL which provides a
4//! binding to all APIs that browsers provide on the web.
5//!
6//! This crate by default contains very little when compiled as almost all of
7//! its exposed APIs are gated by Cargo features. The exhaustive list of
8//! features can be found in `crates/web-sys/Cargo.toml`, but the rule of thumb
9//! for `web-sys` is that each type has its own cargo feature (named after the
10//! type). Using an API requires enabling the features for all types used in the
11//! API, and APIs should mention in the documentation what features they
12//! require.
13
14#![doc(html_root_url = "https://docs.rs/web-sys/0.3")]
15#![no_std]
16#![allow(deprecated)]
17
18extern crate alloc;
19
20mod features;
21#[allow(unused_imports)]
22pub use features::*;
23
24pub use js_sys;
25pub use wasm_bindgen;
26
27/// Getter for the `Window` object
28///
29/// [MDN Documentation]
30///
31/// *This API requires the following crate features to be activated: `Window`*
32///
33/// [MDN Documentation]: https://developer.mozilla.org/en-US/docs/Web/API/Window
34#[cfg(feature = "Window")]
35pub fn window() -> Option<Window> {
36    use wasm_bindgen::JsCast;
37
38    js_sys::global().dyn_into::<Window>().ok()
39}