{"doc_urls":["introduction.html#introduction","examples/index.html#examples-of-using-wasm-bindgen-js-sys-and-web-sys","examples/hello-world.html#hello-world","examples/hello-world.html#cargotoml","examples/hello-world.html#srclibrs","examples/hello-world.html#indexjs","examples/hello-world.html#webpack-specific-files","examples/console-log.html#consolelog","examples/console-log.html#srclibrs","examples/add.html#small-wasm-files","examples/without-a-bundler.html#without-a-bundler","examples/without-a-bundler.html#using-the-older---target-no-modules","examples/wasm2js.html#converting-webassembly-to-js","examples/import-js.html#importing-non-browser-js","examples/char.html#working-with-the-char-type","examples/char.html#srclibrs","examples/char.html#indexjs","examples/wasm-in-wasm.html#js-sys-webassembly-in-webassembly","examples/wasm-in-wasm.html#srclibrs","examples/dom.html#web-sys-dom-hello-world","examples/dom.html#cargotoml","examples/dom.html#srclibrs","examples/closures.html#web-sys-closures","examples/closures.html#srclibrs","examples/performance.html#web-sys-performancenow","examples/performance.html#srclibrs","examples/fetch.html#the-fetch-api","examples/fetch.html#cargotoml","examples/fetch.html#srclibrs","examples/2d-canvas.html#2d-canvas","examples/2d-canvas.html#cargotoml","examples/2d-canvas.html#srclibrs","examples/julia.html#julia-set","examples/julia.html#indexjs","examples/julia.html#srclibrs","examples/web-audio.html#webaudio","examples/web-audio.html#cargotoml","examples/web-audio.html#srclibrs","examples/web-audio.html#indexjs","examples/webgl.html#webgl-example","examples/webgl.html#cargotoml","examples/webgl.html#srclibrs","examples/websockets.html#websockets-example","examples/websockets.html#cargotoml","examples/websockets.html#srclibrs","examples/webrtc_datachannel.html#webrtc-datachannel-example","examples/webrtc_datachannel.html#cargotoml","examples/webrtc_datachannel.html#srclibrs","examples/request-animation-frame.html#web-sys-a-requestanimationframe-loop","examples/request-animation-frame.html#cargotoml","examples/request-animation-frame.html#srclibrs","examples/paint.html#paint-example","examples/paint.html#cargotoml","examples/paint.html#srclibrs","examples/raytrace.html#parallel-raytracing","examples/todomvc.html#todo-mvc-using-wasm-bingen-and-web-sys","examples/todomvc.html#size","reference/index.html#reference","reference/deployment.html#deploying-rust-and-webassembly","reference/deployment.html#bundlers","reference/deployment.html#without-a-bundler","reference/deployment.html#nodejs","reference/deployment.html#deno","reference/deployment.html#npm","reference/js-snippets.html#js-snippets","reference/js-snippets.html#using-inline_js","reference/js-snippets.html#caveats","reference/passing-rust-closures-to-js.html#passing-rust-closures-to-imported-javascript-functions","reference/passing-rust-closures-to-js.html#stack-lifetime-closures","reference/passing-rust-closures-to-js.html#heap-allocated-closures","reference/receiving-js-closures-in-rust.html#receiving-javascript-closures-in-exported-rust-functions","reference/js-promises-and-rust-futures.html#working-with-a-js-promise-and-a-rust-future","reference/js-promises-and-rust-futures.html#return-values-of-async-fn","reference/js-promises-and-rust-futures.html#using-wasm-bindgen-futures","reference/js-promises-and-rust-futures.html#compatibility-with-versions-of-future","reference/iterating-over-js-values.html#iterating-over-javascript-values","reference/iterating-over-js-values.html#methods-that-return-js_sysiterator","reference/iterating-over-js-values.html#iterating-over-any-javascript-object-that-implements-the-iterator-protocol","reference/arbitrary-data-with-serde.html#serializing-and-deserializing-arbitrary-data-into-and-from-jsvalue-with-serde","reference/arbitrary-data-with-serde.html#enable-the-serde-serialize-feature","reference/arbitrary-data-with-serde.html#import-serdes-custom-derive-macros","reference/arbitrary-data-with-serde.html#derive-the-serialize-and-deserialize-traits","reference/arbitrary-data-with-serde.html#send-it-to-javascript-with-jsvaluefrom_serde","reference/arbitrary-data-with-serde.html#receive-it-from-javascript-with-jsvalueinto_serde","reference/arbitrary-data-with-serde.html#javascript-usage","reference/arbitrary-data-with-serde.html#an-alternative-approach-serde-wasm-bindgen","reference/accessing-properties-of-untyped-js-values.html#accessing-properties-of-untyped-javascript-values","reference/accessing-properties-of-untyped-js-values.html#reading-properties-with-js_sysreflectget","reference/accessing-properties-of-untyped-js-values.html#writing-properties-with-js_sysreflectset","reference/accessing-properties-of-untyped-js-values.html#determining-if-a-property-exists-with-js_sysreflecthas","reference/accessing-properties-of-untyped-js-values.html#but-wait--theres-more","reference/working-with-duck-typed-interfaces.html#working-with-duck-typed-interfaces","reference/working-with-duck-typed-interfaces.html#defining-a-duck-typed-interface-in-rust","reference/working-with-duck-typed-interfaces.html#javascript-usage","reference/cli.html#the-wasm-bindgen-command-line-interface","reference/cli.html#installation","reference/cli.html#usage","reference/cli.html#options","reference/cli.html#--out-dir-dir","reference/cli.html#--target","reference/cli.html#--no-modules-global-var","reference/cli.html#--typescript","reference/cli.html#--no-typescript","reference/cli.html#--omit-imports","reference/cli.html#--debug","reference/cli.html#--no-demangle","reference/cli.html#--keep-debug","reference/cli.html#--browser","reference/optimize-size.html#optimizing-for-size-with-wasm-bindgen","reference/optimize-size.html#what-to-profile","reference/optimize-size.html#example","reference/rust-targets.html#supported-rust-targets","reference/rust-targets.html#non-wasm-targets","reference/rust-targets.html#other-web-targets","reference/browser-support.html#supported-browsers","reference/browser-support.html#caveats","reference/types.html#supported-rust-types-and-their-javascript-representations","reference/types/imported-js-types.html#imported-extern-whatever-javascript-types","reference/types/imported-js-types.html#example-rust-usage","reference/types/imported-js-types.html#example-javascript-usage","reference/types/exported-rust-types.html#exported-struct-whatever-rust-types","reference/types/exported-rust-types.html#example-rust-usage","reference/types/exported-rust-types.html#example-javascript-usage","reference/types/jsvalue.html#jsvalue","reference/types/jsvalue.html#example-rust-usage","reference/types/jsvalue.html#example-javascript-usage","reference/types/boxed-jsvalue-slice.html#boxjsvalue","reference/types/boxed-jsvalue-slice.html#example-rust-usage","reference/types/boxed-jsvalue-slice.html#example-javascript-usage","reference/types/pointers.html#const-t-and-mut-t","reference/types/pointers.html#example-rust-usage","reference/types/pointers.html#example-javascript-usage","reference/types/numbers.html#numbers-u8-i8-u16-i16-u32-i32-u64-i64-isize-usize-f32-and-f64","reference/types/numbers.html#example-rust-usage","reference/types/numbers.html#example-javascript-usage","reference/types/bool.html#bool","reference/types/bool.html#example-rust-usage","reference/types/bool.html#example-javascript-usage","reference/types/char.html#char","reference/types/char.html#example-rust-usage","reference/types/char.html#example-javascript-usage","reference/types/str.html#str","reference/types/str.html#example-rust-usage","reference/types/str.html#example-javascript-usage","reference/types/str.html#utf-16-vs-utf-8","reference/types/string.html#string","reference/types/string.html#example-rust-usage","reference/types/string.html#example-javascript-usage","reference/types/number-slices.html#number-slices-u8-i8-u16-i16-u32-i32-u64-i64-f32-and-f64","reference/types/number-slices.html#example-rust-usage","reference/types/number-slices.html#example-javascript-usage","reference/types/boxed-number-slices.html#boxed-number-slices-boxu8-boxi8-boxu16-boxi16-boxu32-boxi32-boxu64-boxi64-boxf32-and-boxf64","reference/types/boxed-number-slices.html#example-rust-usage","reference/types/boxed-number-slices.html#example-javascript-usage","reference/types/result.html#resultt-jsvalue","reference/attributes/index.html#wasm_bindgen-attributes","reference/attributes/on-js-imports/index.html#wasm_bindgen-on-javascript-imports","reference/attributes/on-js-imports/catch.html#catch","reference/attributes/on-js-imports/constructor.html#constructor","reference/attributes/on-js-imports/extends.html#extends--class","reference/attributes/on-js-imports/getter-and-setter.html#getter-and-setter","reference/attributes/on-js-imports/final.html#final","reference/attributes/on-js-imports/final.html#interaction-with-future-proposals","reference/attributes/on-js-imports/indexing-getter-setter-deleter.html#indexing_getter-indexing_setter-and-indexing_deleter","reference/attributes/on-js-imports/js_class.html#js_class--blah","reference/attributes/on-js-imports/js_name.html#js_name--blah","reference/attributes/on-js-imports/js_namespace.html#js_namespace--blah","reference/attributes/on-js-imports/method.html#method","reference/attributes/on-js-imports/module.html#module--blah","reference/attributes/on-js-imports/raw_module.html#raw_module--blah","reference/attributes/on-js-imports/static_method_of.html#static_method_of--blah","reference/attributes/on-js-imports/structural.html#structural","reference/attributes/on-js-imports/variadic.html#variadic-parameters","reference/attributes/on-js-imports/vendor_prefix.html#vendor-prefixed-apis","reference/attributes/on-rust-exports/index.html#wasm_bindgen-on-rust-exports","reference/attributes/on-rust-exports/constructor.html#constructor","reference/attributes/on-rust-exports/js_name.html#js_name--blah","reference/attributes/on-rust-exports/readonly.html#readonly","reference/attributes/on-rust-exports/skip.html#skip","reference/attributes/on-rust-exports/start.html#start","reference/attributes/on-rust-exports/typescript_custom_section.html#typescript_custom_section","reference/attributes/on-rust-exports/getter-and-setter.html#getter-and-setter","reference/attributes/on-rust-exports/inspectable.html#inspectable","reference/attributes/on-rust-exports/inspectable.html#inspectable-classes-in-nodejs","reference/attributes/on-rust-exports/skip_typescript.html#skip_typescript","reference/attributes/on-rust-exports/typescript_type.html#typescript_type","web-sys/index.html#the-web-sys-crate","web-sys/index.html#api-documentation","web-sys/using-web-sys.html#using-web-sys","web-sys/using-web-sys.html#add-web-sys-as-a-dependency-to-your-cargotoml","web-sys/using-web-sys.html#enable-the-cargo-features-for-the-apis-youre-using","web-sys/using-web-sys.html#call-the-method","web-sys/cargo-features.html#cargo-features-in-web-sys","web-sys/function-overloads.html#function-overloads","web-sys/type-translations.html#type-translations-in-web-sys","web-sys/inheritance.html#inheritance-in-web-sys","web-sys/inheritance.html#accessing-parent-classes-using-deref","web-sys/inheritance.html#accessing-parent-classes-using-asref","web-sys/inheritance.html#accessing-child-clases-using-jscast","web-sys/unstable-apis.html#unstable-apis","wasm-bindgen-test/index.html#testing-on-wasm32-unknown-unknown-with-wasm-bindgen-test","wasm-bindgen-test/index.html#goals","wasm-bindgen-test/usage.html#using-wasm-bindgen-test","wasm-bindgen-test/usage.html#add-wasm-bindgen-test-to-your-cargotomls-dev-dependencies","wasm-bindgen-test/usage.html#write-some-tests","wasm-bindgen-test/usage.html#execute-your-tests","wasm-bindgen-test/usage.html#appendix-using-wasm-bindgen-test-without-wasm-pack","wasm-bindgen-test/usage.html#install-the-test-runner","wasm-bindgen-test/usage.html#configure-cargoconfig-to-use-the-test-runner","wasm-bindgen-test/usage.html#run-the-tests","wasm-bindgen-test/asynchronous-tests.html#writing-asynchronous-tests","wasm-bindgen-test/asynchronous-tests.html#rust-compiler-compatibility","wasm-bindgen-test/browsers.html#testing-in-headless-browsers","wasm-bindgen-test/browsers.html#configure-your-test-crate","wasm-bindgen-test/browsers.html#configuring-which-browser-is-used","wasm-bindgen-test/browsers.html#running-the-tests-in-the-headless-browser","wasm-bindgen-test/browsers.html#configuring-headless-browser-capabilities","wasm-bindgen-test/browsers.html#debugging-headless-browser-tests","wasm-bindgen-test/browsers.html#appendix-testing-in-headless-browsers-without-wasm-pack","wasm-bindgen-test/browsers.html#configuring-which-browser-is-used","wasm-bindgen-test/browsers.html#running-the-tests-in-the-remote-headless-browser","wasm-bindgen-test/browsers.html#running-the-tests-in-the-headless-browser","wasm-bindgen-test/continuous-integration.html#setting-up-continuous-integration-with-wasm-bindgen-test","wasm-bindgen-test/continuous-integration.html#travis-ci","wasm-bindgen-test/continuous-integration.html#appveyor","wasm-bindgen-test/continuous-integration.html#github-actions","contributing/index.html#contributing-to-wasm-bindgen","contributing/index.html#prerequisites","contributing/index.html#code-formatting","contributing/testing.html#running-wasm-bindgens-tests","contributing/testing.html#wasm-tests-on-node-and-headless-browsers","contributing/testing.html#sanity-tests-for-wasm-bindgen-on-the-native-host-target","contributing/testing.html#the-web-idl-frontends-tests","contributing/testing.html#the-macro-ui-tests","contributing/testing.html#the-js-sys-tests","contributing/testing.html#the-web-sys-tests","contributing/design/index.html#design-of-wasm-bindgen","contributing/design/index.html#foundation-es-modules","contributing/design/index.html#foundation-2-unintrusive-in-rust","contributing/design/js-objects-in-rust.html#polyfill-for-js-objects-in-wasm","contributing/design/js-objects-in-rust.html#temporary-js-objects-on-the-stack","contributing/design/js-objects-in-rust.html#long-lived-js-objects","contributing/design/js-objects-in-rust.html#anatomy-of-jsvalue","contributing/design/js-objects-in-rust.html#working-with-heap-in-reality","contributing/design/exporting-rust.html#exporting-a-function-to-js","contributing/design/exporting-rust-struct.html#exporting-a-struct-to-js","contributing/design/importing-js.html#importing-a-function-from-js","contributing/design/importing-js-struct.html#importing-a-class-from-js","contributing/design/rust-type-conversions.html#rust-type-conversions","contributing/design/rust-type-conversions.html#from-rust-to-js","contributing/design/rust-type-conversions.html#from-js-to-rust","contributing/design/rust-type-conversions.html#global-stack","contributing/design/describe.html#communicating-types-to-wasm-bindgen","contributing/js-sys/index.html#js-sys","contributing/js-sys/testing.html#testing","contributing/js-sys/adding-more-apis.html#adding-support-for-more-javascript-global-apis","contributing/js-sys/adding-more-apis.html#instructions-for-adding-an-api","contributing/web-sys/index.html#web-sys","contributing/web-sys/overview.html#web-sys-overview","contributing/web-sys/overview.html#webidlsenabledwebidl","contributing/web-sys/overview.html#buildrs","contributing/web-sys/overview.html#srclibrs","contributing/web-sys/overview.html#cargo-features","contributing/web-sys/testing.html#testing","contributing/web-sys/logging.html#logging","contributing/web-sys/supporting-more-web-apis.html#supporting-more-web-apis-in-web-sys","contributing/publishing.html#publishing-new-wasm-bindgen-releases","contributing/team.html#team","contributing/team.html#members"],"index":{"documentStore":{"docInfo":{"0":{"body":177,"breadcrumbs":1,"title":1},"1":{"body":82,"breadcrumbs":8,"title":8},"10":{"body":263,"breadcrumbs":3,"title":2},"100":{"body":15,"breadcrumbs":4,"title":3},"101":{"body":8,"breadcrumbs":2,"title":1},"102":{"body":11,"breadcrumbs":2,"title":1},"103":{"body":42,"breadcrumbs":3,"title":2},"104":{"body":16,"breadcrumbs":2,"title":1},"105":{"body":10,"breadcrumbs":2,"title":1},"106":{"body":10,"breadcrumbs":3,"title":2},"107":{"body":18,"breadcrumbs":2,"title":1},"108":{"body":46,"breadcrumbs":5,"title":4},"109":{"body":136,"breadcrumbs":2,"title":1},"11":{"body":121,"breadcrumbs":5,"title":4},"110":{"body":18,"breadcrumbs":2,"title":1},"111":{"body":40,"breadcrumbs":4,"title":3},"112":{"body":93,"breadcrumbs":4,"title":3},"113":{"body":25,"breadcrumbs":3,"title":2},"114":{"body":52,"breadcrumbs":3,"title":2},"115":{"body":193,"breadcrumbs":2,"title":1},"116":{"body":13,"breadcrumbs":6,"title":5},"117":{"body":29,"breadcrumbs":8,"title":5},"118":{"body":65,"breadcrumbs":6,"title":3},"119":{"body":29,"breadcrumbs":6,"title":3},"12":{"body":154,"breadcrumbs":4,"title":3},"120":{"body":28,"breadcrumbs":8,"title":5},"121":{"body":50,"breadcrumbs":6,"title":3},"122":{"body":31,"breadcrumbs":6,"title":3},"123":{"body":22,"breadcrumbs":4,"title":1},"124":{"body":18,"breadcrumbs":6,"title":3},"125":{"body":9,"breadcrumbs":6,"title":3},"126":{"body":24,"breadcrumbs":4,"title":1},"127":{"body":25,"breadcrumbs":6,"title":3},"128":{"body":28,"breadcrumbs":6,"title":3},"129":{"body":22,"breadcrumbs":7,"title":4},"13":{"body":124,"breadcrumbs":5,"title":4},"130":{"body":17,"breadcrumbs":6,"title":3},"131":{"body":20,"breadcrumbs":6,"title":3},"132":{"body":24,"breadcrumbs":16,"title":13},"133":{"body":24,"breadcrumbs":6,"title":3},"134":{"body":22,"breadcrumbs":6,"title":3},"135":{"body":24,"breadcrumbs":4,"title":1},"136":{"body":24,"breadcrumbs":6,"title":3},"137":{"body":22,"breadcrumbs":6,"title":3},"138":{"body":22,"breadcrumbs":4,"title":1},"139":{"body":12,"breadcrumbs":6,"title":3},"14":{"body":76,"breadcrumbs":4,"title":3},"140":{"body":10,"breadcrumbs":6,"title":3},"141":{"body":48,"breadcrumbs":4,"title":1},"142":{"body":7,"breadcrumbs":6,"title":3},"143":{"body":4,"breadcrumbs":6,"title":3},"144":{"body":117,"breadcrumbs":8,"title":5},"145":{"body":52,"breadcrumbs":4,"title":1},"146":{"body":24,"breadcrumbs":6,"title":3},"147":{"body":22,"breadcrumbs":6,"title":3},"148":{"body":31,"breadcrumbs":15,"title":12},"149":{"body":13,"breadcrumbs":6,"title":3},"15":{"body":74,"breadcrumbs":2,"title":1},"150":{"body":8,"breadcrumbs":6,"title":3},"151":{"body":49,"breadcrumbs":16,"title":13},"152":{"body":24,"breadcrumbs":6,"title":3},"153":{"body":26,"breadcrumbs":6,"title":3},"154":{"body":90,"breadcrumbs":5,"title":2},"155":{"body":22,"breadcrumbs":3,"title":2},"156":{"body":15,"breadcrumbs":6,"title":3},"157":{"body":95,"breadcrumbs":6,"title":1},"158":{"body":51,"breadcrumbs":6,"title":1},"159":{"body":92,"breadcrumbs":7,"title":2},"16":{"body":130,"breadcrumbs":2,"title":1},"160":{"body":178,"breadcrumbs":7,"title":2},"161":{"body":228,"breadcrumbs":6,"title":1},"162":{"body":228,"breadcrumbs":8,"title":3},"163":{"body":186,"breadcrumbs":8,"title":3},"164":{"body":52,"breadcrumbs":7,"title":2},"165":{"body":123,"breadcrumbs":7,"title":2},"166":{"body":97,"breadcrumbs":7,"title":2},"167":{"body":42,"breadcrumbs":6,"title":1},"168":{"body":58,"breadcrumbs":7,"title":2},"169":{"body":58,"breadcrumbs":7,"title":2},"17":{"body":20,"breadcrumbs":5,"title":4},"170":{"body":76,"breadcrumbs":7,"title":2},"171":{"body":119,"breadcrumbs":6,"title":1},"172":{"body":71,"breadcrumbs":7,"title":2},"173":{"body":64,"breadcrumbs":8,"title":3},"174":{"body":11,"breadcrumbs":6,"title":3},"175":{"body":49,"breadcrumbs":6,"title":1},"176":{"body":79,"breadcrumbs":7,"title":2},"177":{"body":66,"breadcrumbs":6,"title":1},"178":{"body":75,"breadcrumbs":6,"title":1},"179":{"body":116,"breadcrumbs":6,"title":1},"18":{"body":96,"breadcrumbs":2,"title":1},"180":{"body":83,"breadcrumbs":6,"title":1},"181":{"body":128,"breadcrumbs":7,"title":2},"182":{"body":125,"breadcrumbs":6,"title":1},"183":{"body":20,"breadcrumbs":8,"title":3},"184":{"body":80,"breadcrumbs":6,"title":1},"185":{"body":88,"breadcrumbs":6,"title":1},"186":{"body":41,"breadcrumbs":3,"title":3},"187":{"body":6,"breadcrumbs":2,"title":2},"188":{"body":0,"breadcrumbs":5,"title":3},"189":{"body":9,"breadcrumbs":7,"title":5},"19":{"body":33,"breadcrumbs":6,"title":5},"190":{"body":53,"breadcrumbs":8,"title":6},"191":{"body":25,"breadcrumbs":4,"title":2},"192":{"body":46,"breadcrumbs":6,"title":4},"193":{"body":63,"breadcrumbs":4,"title":2},"194":{"body":99,"breadcrumbs":6,"title":4},"195":{"body":28,"breadcrumbs":5,"title":3},"196":{"body":48,"breadcrumbs":7,"title":5},"197":{"body":51,"breadcrumbs":7,"title":5},"198":{"body":29,"breadcrumbs":7,"title":5},"199":{"body":111,"breadcrumbs":4,"title":2},"2":{"body":25,"breadcrumbs":3,"title":2},"20":{"body":40,"breadcrumbs":2,"title":1},"200":{"body":18,"breadcrumbs":7,"title":7},"201":{"body":28,"breadcrumbs":1,"title":1},"202":{"body":0,"breadcrumbs":8,"title":4},"203":{"body":31,"breadcrumbs":11,"title":7},"204":{"body":41,"breadcrumbs":6,"title":2},"205":{"body":114,"breadcrumbs":6,"title":2},"206":{"body":31,"breadcrumbs":12,"title":8},"207":{"body":26,"breadcrumbs":7,"title":3},"208":{"body":10,"breadcrumbs":9,"title":5},"209":{"body":15,"breadcrumbs":6,"title":2},"21":{"body":46,"breadcrumbs":2,"title":1},"210":{"body":69,"breadcrumbs":7,"title":3},"211":{"body":57,"breadcrumbs":7,"title":3},"212":{"body":0,"breadcrumbs":7,"title":3},"213":{"body":42,"breadcrumbs":7,"title":3},"214":{"body":50,"breadcrumbs":7,"title":3},"215":{"body":21,"breadcrumbs":8,"title":4},"216":{"body":45,"breadcrumbs":8,"title":4},"217":{"body":12,"breadcrumbs":8,"title":4},"218":{"body":27,"breadcrumbs":11,"title":7},"219":{"body":60,"breadcrumbs":7,"title":3},"22":{"body":28,"breadcrumbs":4,"title":3},"220":{"body":13,"breadcrumbs":9,"title":5},"221":{"body":51,"breadcrumbs":8,"title":4},"222":{"body":20,"breadcrumbs":11,"title":7},"223":{"body":37,"breadcrumbs":6,"title":2},"224":{"body":75,"breadcrumbs":5,"title":1},"225":{"body":33,"breadcrumbs":6,"title":2},"226":{"body":19,"breadcrumbs":3,"title":3},"227":{"body":27,"breadcrumbs":1,"title":1},"228":{"body":26,"breadcrumbs":2,"title":2},"229":{"body":0,"breadcrumbs":7,"title":4},"23":{"body":284,"breadcrumbs":2,"title":1},"230":{"body":37,"breadcrumbs":8,"title":5},"231":{"body":15,"breadcrumbs":10,"title":7},"232":{"body":9,"breadcrumbs":7,"title":4},"233":{"body":18,"breadcrumbs":6,"title":3},"234":{"body":5,"breadcrumbs":6,"title":3},"235":{"body":5,"breadcrumbs":6,"title":3},"236":{"body":27,"breadcrumbs":6,"title":3},"237":{"body":156,"breadcrumbs":6,"title":3},"238":{"body":91,"breadcrumbs":7,"title":4},"239":{"body":39,"breadcrumbs":9,"title":4},"24":{"body":24,"breadcrumbs":4,"title":3},"240":{"body":280,"breadcrumbs":9,"title":4},"241":{"body":262,"breadcrumbs":9,"title":4},"242":{"body":69,"breadcrumbs":7,"title":2},"243":{"body":28,"breadcrumbs":8,"title":3},"244":{"body":378,"breadcrumbs":8,"title":3},"245":{"body":424,"breadcrumbs":8,"title":3},"246":{"body":213,"breadcrumbs":8,"title":3},"247":{"body":508,"breadcrumbs":8,"title":3},"248":{"body":30,"breadcrumbs":8,"title":3},"249":{"body":125,"breadcrumbs":7,"title":2},"25":{"body":65,"breadcrumbs":2,"title":1},"250":{"body":157,"breadcrumbs":7,"title":2},"251":{"body":143,"breadcrumbs":7,"title":2},"252":{"body":179,"breadcrumbs":9,"title":4},"253":{"body":95,"breadcrumbs":5,"title":2},"254":{"body":39,"breadcrumbs":6,"title":1},"255":{"body":41,"breadcrumbs":11,"title":6},"256":{"body":56,"breadcrumbs":8,"title":3},"257":{"body":63,"breadcrumbs":5,"title":2},"258":{"body":13,"breadcrumbs":8,"title":3},"259":{"body":9,"breadcrumbs":6,"title":1},"26":{"body":20,"breadcrumbs":3,"title":2},"260":{"body":16,"breadcrumbs":6,"title":1},"261":{"body":102,"breadcrumbs":6,"title":1},"262":{"body":39,"breadcrumbs":7,"title":2},"263":{"body":42,"breadcrumbs":6,"title":1},"264":{"body":65,"breadcrumbs":6,"title":1},"265":{"body":255,"breadcrumbs":11,"title":6},"266":{"body":37,"breadcrumbs":8,"title":5},"267":{"body":33,"breadcrumbs":4,"title":1},"268":{"body":9,"breadcrumbs":4,"title":1},"27":{"body":65,"breadcrumbs":2,"title":1},"28":{"body":132,"breadcrumbs":2,"title":1},"29":{"body":22,"breadcrumbs":3,"title":2},"3":{"body":35,"breadcrumbs":2,"title":1},"30":{"body":41,"breadcrumbs":2,"title":1},"31":{"body":85,"breadcrumbs":2,"title":1},"32":{"body":19,"breadcrumbs":3,"title":2},"33":{"body":42,"breadcrumbs":2,"title":1},"34":{"body":173,"breadcrumbs":2,"title":1},"35":{"body":17,"breadcrumbs":2,"title":1},"36":{"body":40,"breadcrumbs":2,"title":1},"37":{"body":274,"breadcrumbs":2,"title":1},"38":{"body":56,"breadcrumbs":2,"title":1},"39":{"body":15,"breadcrumbs":3,"title":2},"4":{"body":24,"breadcrumbs":2,"title":1},"40":{"body":44,"breadcrumbs":2,"title":1},"41":{"body":225,"breadcrumbs":2,"title":1},"42":{"body":18,"breadcrumbs":3,"title":2},"43":{"body":46,"breadcrumbs":2,"title":1},"44":{"body":252,"breadcrumbs":2,"title":1},"45":{"body":24,"breadcrumbs":4,"title":3},"46":{"body":48,"breadcrumbs":2,"title":1},"47":{"body":254,"breadcrumbs":2,"title":1},"48":{"body":28,"breadcrumbs":5,"title":4},"49":{"body":42,"breadcrumbs":2,"title":1},"5":{"body":29,"breadcrumbs":2,"title":1},"50":{"body":157,"breadcrumbs":2,"title":1},"51":{"body":11,"breadcrumbs":3,"title":2},"52":{"body":48,"breadcrumbs":2,"title":1},"53":{"body":112,"breadcrumbs":2,"title":1},"54":{"body":86,"breadcrumbs":3,"title":2},"55":{"body":42,"breadcrumbs":8,"title":7},"56":{"body":17,"breadcrumbs":2,"title":1},"57":{"body":36,"breadcrumbs":1,"title":1},"58":{"body":78,"breadcrumbs":4,"title":3},"59":{"body":77,"breadcrumbs":2,"title":1},"6":{"body":103,"breadcrumbs":4,"title":3},"60":{"body":99,"breadcrumbs":3,"title":2},"61":{"body":54,"breadcrumbs":2,"title":1},"62":{"body":19,"breadcrumbs":2,"title":1},"63":{"body":13,"breadcrumbs":2,"title":1},"64":{"body":108,"breadcrumbs":3,"title":2},"65":{"body":58,"breadcrumbs":3,"title":2},"66":{"body":96,"breadcrumbs":2,"title":1},"67":{"body":31,"breadcrumbs":7,"title":6},"68":{"body":68,"breadcrumbs":4,"title":3},"69":{"body":168,"breadcrumbs":4,"title":3},"7":{"body":21,"breadcrumbs":2,"title":1},"70":{"body":69,"breadcrumbs":7,"title":6},"71":{"body":121,"breadcrumbs":6,"title":5},"72":{"body":107,"breadcrumbs":5,"title":4},"73":{"body":40,"breadcrumbs":5,"title":4},"74":{"body":39,"breadcrumbs":4,"title":3},"75":{"body":0,"breadcrumbs":5,"title":4},"76":{"body":135,"breadcrumbs":4,"title":3},"77":{"body":75,"breadcrumbs":8,"title":7},"78":{"body":18,"breadcrumbs":7,"title":6},"79":{"body":32,"breadcrumbs":5,"title":4},"8":{"body":165,"breadcrumbs":2,"title":1},"80":{"body":17,"breadcrumbs":6,"title":5},"81":{"body":63,"breadcrumbs":5,"title":4},"82":{"body":31,"breadcrumbs":4,"title":3},"83":{"body":16,"breadcrumbs":4,"title":3},"84":{"body":39,"breadcrumbs":3,"title":2},"85":{"body":87,"breadcrumbs":6,"title":5},"86":{"body":30,"breadcrumbs":6,"title":5},"87":{"body":16,"breadcrumbs":4,"title":3},"88":{"body":21,"breadcrumbs":4,"title":3},"89":{"body":22,"breadcrumbs":5,"title":4},"9":{"body":186,"breadcrumbs":4,"title":3},"90":{"body":11,"breadcrumbs":4,"title":3},"91":{"body":35,"breadcrumbs":5,"title":4},"92":{"body":50,"breadcrumbs":6,"title":5},"93":{"body":33,"breadcrumbs":3,"title":2},"94":{"body":36,"breadcrumbs":6,"title":5},"95":{"body":124,"breadcrumbs":2,"title":1},"96":{"body":6,"breadcrumbs":2,"title":1},"97":{"body":0,"breadcrumbs":2,"title":1},"98":{"body":11,"breadcrumbs":4,"title":3},"99":{"body":25,"breadcrumbs":2,"title":1}},"docs":{"0":{"body":"This book is about wasm-bindgen, a Rust library and CLI tool that facilitate high-level interactions between wasm modules and JavaScript. The wasm-bindgen tool and crate are only one part of the Rust and WebAssembly ecosystem . If you're not familiar already with wasm-bindgen it's recommended to start by reading the Game of Life tutorial . If you're curious about wasm-pack, you can find that documentation here . The wasm-bindgen tool is sort of half polyfill for features like the host bindings proposal and half features for empowering high-level interactions between JS and wasm-compiled code (currently mostly from Rust). More specifically this project allows JS/wasm to communicate with strings, JS objects, classes, etc, as opposed to purely integers and floats. Using wasm-bindgen for example you can define a JS class in Rust or take a string from JS or return one. The functionality is growing as well! Currently this tool is Rust-focused but the underlying foundation is language-independent, and it's hoping that over time as this tool stabilizes that it can be used for languages like C/C++! Notable features of this project includes: Importing JS functionality in to Rust such as DOM manipulation , console logging , or performance monitoring . Exporting Rust functionality to JS such as classes, functions, etc. Working with rich types like strings, numbers, classes, closures, and objects rather than simply u32 and floats. Automatically generating TypeScript bindings for Rust code being consumed by JS. With the addition of wasm-pack you can run the gamut from running Rust on the web locally, publishing it as part of a larger application, or even publishing Rust-compiled-to-WebAssembly on NPM!","breadcrumbs":"Introduction","id":"0","title":"Introduction"},"1":{"body":"This subsection contains examples of using the wasm-bindgen, js-sys, and web-sys crates. Each example should have more information about what it's doing. These examples all assume familiarity with wasm-bindgen, wasm-pack, and building a Rust and WebAssembly project. If you're unfamiliar with these check out the Game of Life tutorial or wasm pack tutorials to help you get started. The source code for all examples can also be found online to download and run locally. Most examples are configured with Webpack/wasm-pack and can be built with npm run serve. Other examples which don't use Webpack are accompanied with instructions or a build.sh showing how to build it. Note that most examples currently use Webpack to assemble the final output artifact, but this is not required! You can review the deployment documentation for other options of how to deploy Rust and WebAssembly.","breadcrumbs":"Examples of using wasm-bindgen, js-sys, and web-sys","id":"1","title":"Examples of using wasm-bindgen, js-sys, and web-sys"},"10":{"body":"View full source code This example shows how the --target web flag can be used load code in a browser directly. For this deployment strategy bundlers like Webpack are not required. For more information on deployment see the dedicated documentation . First let's take a look at the code and see how when we're using --target web we're not actually losing any functionality! use wasm_bindgen::prelude::*; // Called when the wasm module is instantiated\n#[wasm_bindgen(start)]\npub fn main() -> Result<(), JsValue> { // Use `web_sys`'s global `window` function to get a handle on the global // window object. let window = web_sys::window().expect(\"no global `window` exists\"); let document = window.document().expect(\"should have a document on window\"); let body = document.body().expect(\"document should have a body\"); // Manufacture the element we're gonna append let val = document.create_element(\"p\")?; val.set_inner_html(\"Hello from Rust!\"); body.append_child(&val)?; Ok(())\n} #[wasm_bindgen]\npub fn add(a: u32, b: u32) -> u32 { a + b\n} Otherwise the rest of the deployment magic happens in index.html: \n And that's it! Be sure to read up on the deployment options to see what it means to deploy without a bundler.","breadcrumbs":"Examples » Without a Bundler","id":"10","title":"Without a Bundler"},"100":{"body":"When --target no-modules is used this flag can indicate what the name of the global to assign generated bindings to. For more information about this see the section on deployment","breadcrumbs":"Reference » --no-modules-global VAR","id":"100","title":"--no-modules-global VAR"},"101":{"body":"Output a TypeScript declaration file for the generated JavaScript bindings. This is on by default.","breadcrumbs":"Reference » --typescript","id":"101","title":"--typescript"},"102":{"body":"By default, a *.d.ts TypeScript declaration file is generated for the generated JavaScript bindings, but this flag will disable that.","breadcrumbs":"Reference » --no-typescript","id":"102","title":"--no-typescript"},"103":{"body":"When the module attribute is used with the wasm-bindgen macro, the code generator will emit corresponding import or require statements in the header section of the generated javascript. This flag causes those import statements to be omitted. This is necessary for some use cases, such as generating javascript which is intended to be used with Electron (with node integration disabled), where the imports are instead handled through a separate preload script.","breadcrumbs":"Reference » --omit-imports","id":"103","title":"--omit-imports"},"104":{"body":"Generates a bit more JS and wasm in \"debug mode\" to help catch programmer errors, but this output isn't intended to be shipped to production.","breadcrumbs":"Reference » --debug","id":"104","title":"--debug"},"105":{"body":"When post-processing the .wasm binary, do not demangle Rust symbols in the \"names\" custom section.","breadcrumbs":"Reference » --no-demangle","id":"105","title":"--no-demangle"},"106":{"body":"When post-processing the .wasm binary, do not strip DWARF debug info custom sections.","breadcrumbs":"Reference » --keep-debug","id":"106","title":"--keep-debug"},"107":{"body":"When generating bundler-compatible code (see the section on deployment ) this indicates that the bundled code is always intended to go into a browser so a few checks for Node.js can be elided.","breadcrumbs":"Reference » --browser","id":"107","title":"--browser"},"108":{"body":"The Rust and WebAssembly Working Group's Game of Life tutorial has an excellent section on shrinking wasm code size , but there's a few wasm-bindgen-specific items to mention as well! First and foremost, wasm-bindgen is designed to be lightweight and a \"pay only for what you use\" mentality. If you suspect that wasm-bindgen is bloating your program that is a bug and we'd like to know about it! Please feel free to file an issue , even if it's a question!","breadcrumbs":"Reference » Optimizing for Size with wasm-bindgen","id":"108","title":"Optimizing for Size with wasm-bindgen"},"109":{"body":"With wasm-bindgen there's a few different files to be measuring the size of. The first of which is the output of the compiler itself, typically at target/wasm32-unknown-unknown/release/foo.wasm. This file is not optimized for size and you should not measure it. The output of the compiler when linking with wasm-bindgen is by design larger than it needs to be, the wasm-bindgen CLI tool will automatically strip all unneeded functionality out of the binary. This leaves us with two primary generated files to measure the size of: Generated wasm - after running the wasm-bindgen CLI tool you'll get a file in --out-dir that looks like foo_bg.wasm. This file is the final fully-finished artifact from wasm-bindgen, and it reflects the size of the app you'll be publishing. All the optimizations mentioned in the code size tutorial will help reduce the size of this binary, so feel free to go crazy! Generated JS - the other file after running wasm-bindgen is a foo.js file which is what's actually imported by other JS code. This file is already generated to be as small as possible (not including unneeded functionality). The JS, however, is not uglified or minified, but rather still human readable and debuggable. It's expected that you'll run an uglifier or bundler of the JS output to minimize it further in your application. If you spot a way we could reduce the output JS size further (or make it more amenable to bundler minification), please let us know!","breadcrumbs":"Reference » What to profile","id":"109","title":"What to profile"},"11":{"body":"View full source code The older version of using wasm-bindgen without a bundler is to use the --target no-modules flag to the wasm-bindgen CLI. While similar to the newer --target web, the --target no-modules flag has a few caveats: It does not support local JS snippets It does not generate an ES module With that in mind the main difference is how the wasm/JS code is loaded, and here's an example of loading the output of wasm-pack for the same module as above. \n","breadcrumbs":"Examples » Using the older --target no-modules","id":"11","title":"Using the older --target no-modules"},"110":{"body":"As an example, the wasm-bindgen repository contains an example about generating small wasm binaries and shows off how to generate a small wasm file for adding two numbers.","breadcrumbs":"Reference » Example","id":"110","title":"Example"},"111":{"body":"Note : This section is about Rust target triples, not targets like node/web workers/browsers. More information on that coming soon! The wasm-bindgen project is designed to target the wasm32-unknown-unknown target in Rust. This target is a \"bare bones\" target for Rust which emits WebAssembly as output. The standard library is largely inert as modules like std::fs and std::net will simply return errors.","breadcrumbs":"Reference » Supported Rust Targets","id":"111","title":"Supported Rust Targets"},"112":{"body":"Note that wasm-bindgen also aims to compile on all targets. This means that it should be safe, if you like, to use #[wasm_bindgen] even when compiling for Windows (for example). For example: #[wasm_bindgen]\npub fn add(a: u32, b: u32) -> u32 { a + b\n} #[cfg(not(target_arch = \"wasm32\"))]\nfn main() { println!(\"1 + 2 = {}\", add(1, 2));\n} This program will compile and work on all platforms, not just wasm32-unknown-unknown. Note that imported functions with #[wasm_bindgen] will unconditionally panic on non-wasm targets. For example: #[wasm_bindgen]\nextern \"C\" { #[wasm_bindgen(js_namespace = console)] fn log(s: &str);\n} fn main() { log(\"hello!\");\n} This program will unconditionally panic on all platforms other than wasm32-unknown-unknown. For better compile times, however, you likely want to only use #[wasm_bindgen] on the wasm32-unknown-unknown target. You can have a target-specific dependency like so: [target.'cfg(target_arch = \"wasm32\")'.dependencies]\nwasm-bindgen = \"0.2\" And in your code you can use: #[cfg(target_arch = \"wasm32\")]\n#[wasm_bindgen]\npub fn only_on_the_wasm_target() { // ...\n}","breadcrumbs":"Reference » Non-wasm targets","id":"112","title":"Non-wasm targets"},"113":{"body":"The wasm-bindgen target does not support the wasm32-unknown-emscripten nor the asmjs-unknown-emscripten targets. There are currently no plans to support these targets either. All annotations work like other platforms on the targets, retaining exported functions and causing all imports to panic.","breadcrumbs":"Reference » Other Web Targets","id":"113","title":"Other Web Targets"},"114":{"body":"The output of wasm-bindgen includes a JS file, and as a result it's good to know what browsers that file is expected to be used in! By default the output uses ES modules which isn't implemented in all browsers today, but when using a bundler (like Webpack) you should be able to produce output suitable for all browsers. Firefox, Chrome, Safari, and Edge browsers are all supported by wasm-bindgen. If you find a problem in one of these browsers please report it as we'd like to fix the bug! If you find a bug in another browser we would also like to be aware of it!","breadcrumbs":"Reference » Supported Browsers","id":"114","title":"Supported Browsers"},"115":{"body":"IE 11 - wasm-bindgen by default requires support for WebAssembly, but no version of IE currently supports WebAssembly. You can support IE by compiling wasm files to JS using wasm2js (you can see an example of doing this too ). Note that at this time no bundler will do this by default, but we'd love to document plugins which do this if you are aware of one! Edge - the TextEncoder and TextDecoder APIs are not currently available in Edge which wasm-bindgen uses to encode/decode strings between JS and Rust. You can polyfill this with at least one of two strategies: If using a bundler, you can likely configure the bundler to polyfill these types by default. For example if you're using Webpack you can use the ProvidePlugin interface like so after also adding text-encoding to your package.json const webpack = require('webpack'); module.exports = { plugins: [ new webpack.ProvidePlugin({ TextDecoder: ['text-encoding', 'TextDecoder'], TextEncoder: ['text-encoding', 'TextEncoder'] }) ] // ... other configuration options\n}; Warning: doing this implies the polyfill will always be used, even if native APIs are available. This has a very significant performance impact (the polyfill was measured to be 100x slower in Chromium)! If you're not using a bundler you can also include support manually by adding a