Debian Codegraph @

.cargo/vendor/wasm-bindgen/guide/src/contributing/web-sys/overview.md

raw
1 # `web-sys` Overview
2
3 The `web-sys` crate has this file and directory layout:
4
5 ```text
6 .
7 ├── build.rs
8 ├── Cargo.toml
9 ├── README.md
10 ├── src
11 │ └── lib.rs
12 └── webidls
13 └── enabled
14 └── ...
15 ```
16
17 ### `webidls/enabled/*.webidl`
18
19 These are the WebIDL interfaces that we will actually generate bindings for (or
20 at least bindings for *some* of the things defined in these files).
21
22 ### `build.rs`
23
24 The `build.rs` invokes `wasm-bindgen`'s WebIDL frontend on all the WebIDL files
25 in `webidls/enabled`. It writes the resulting bindings into the cargo build's
26 out directory.
27
28 ### `src/lib.rs`
29
30 The only thing `src/lib.rs` does is include the bindings generated at compile
31 time in `build.rs`. Here is the whole `src/lib.rs` file:
32
33 ```rust
34 {{#include ../../../../crates/web-sys/src/lib.rs}}
35 ```
36
37 ### Cargo features
38
39 When compiled the crate is almost empty by default, which probably isn't what
40 you want! Due to the very large number of APIs, this crate uses features to
41 enable portions of its API to reduce compile times. The list of features in
42 `Cargo.toml` all correspond to types in the generated functions. Enabling a
43 feature enables that type. All methods should indicate what features need to be
44 activated to use the method.