Expand description
Bindings to JavaScript’s standard, built-in objects, including their methods and properties.
This does not include any Web, Node, or any other JS environment APIs. Only the things that are guaranteed to exist in the global scope by the ECMAScript standard.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects
§A Note About camelCase, snake_case, and Naming Conventions
JavaScript’s global objects use camelCase naming conventions for functions
and methods, but Rust style is to use snake_case. These bindings expose
the Rust style snake_case name. Additionally, acronyms within a method
name are all lower case, where as in JavaScript they are all upper case. For
example, decodeURI in JavaScript is exposed as decode_uri in these
bindings.
§A Note About toString and to_js_string
JavaScript’s toString() method is exposed as to_js_string() in these
bindings to avoid confusion with Rust’s ToString trait and its
to_string() method. This allows types to implement both the Rust
Display trait (which provides to_string() via
ToString) and still expose the JavaScript toString() functionality.
Re-exports§
pub use wasm_bindgen;
Modules§
- Atomics
- The
Atomicsobject provides atomic operations as static methods. They are used withSharedArrayBufferobjects. - Intl
- JSON
- The
JSONobject contains methods for parsing JavaScript Object Notation (JSON) and converting values to JSON. It can’t be called or constructed, and aside from its two method properties, it has no interesting functionality of its own. - Math
- Reflect
- WebAssembly
- futures
- Bridging between JavaScript
Promises and RustFutures.
Structs§
- Aggregate
Error - The
AggregateErrorobject represents an error when several errors need to be wrapped in a single error. It is thrown when multiple errors need to be reported by an operation, for example byPromise::any, when all promises passed to it reject. - Array
- Array
Buffer - Array
Buffer Options - Array
Into Iter - Iterator returned by
Array::into_iter - Array
Iter - Iterator returned by
Array::iter - Array
Tuple - Async
Generator - Async
Iterator - Any object that conforms to the JS async iterator protocol. For example,
something returned by
myObject[Symbol.asyncIterator](). - BigInt
- BigInt64
Array - BigUint64
Array - Boolean
- Data
View - Date
- Error
- Error
Options - The options dictionary accepted as the second argument to the
Errorconstructor (and other built-in error constructors such asAggregateError). Its sole standard property iscause, which indicates the original cause of the error. - Eval
Error - Finalization
Registry - The
FinalizationRegistryobject lets you request a callback when an object is garbage-collected. - Float16
Array - Float32
Array - Float64
Array - Function
Functionrepresents any generic Function in JS, by treating all arguments asJsValue.- Generator
- Int8
Array - Int16
Array - Int32
Array - Into
Iter - An iterator over the JS
Symbol.iteratoriteration protocol. - Iter
- An iterator over the JS
Symbol.iteratoriteration protocol. - Iterator
- Any object that conforms to the JS iterator protocol. For example,
something returned by
myArray[Symbol.iterator](). - Iterator
Next - The result of calling
next()on a JS iterator. - JsOption
- A nullable JS value of type
T. - JsString
- Map
- Null
- The JavaScript
nullvalue. - Number
- Object
- Promise
- The
Promiseobject represents the eventual completion (or failure) of an asynchronous operation, and its resulting value. - Promise
State - The
PromiseStateobject represents the the status of the promise, as used inallSettled. - Property
Descriptor - Proxy
- Range
Error - The
RangeErrorobject indicates an error when a value is not in the set or range of allowed values. - Reference
Error - The
ReferenceErrorobject represents an error when a non-existent variable is referenced. - RegExp
- RegExp
Match Array - The result array from
RegExp.exec()orString.matchAll(). - Set
- Shared
Array Buffer - Symbol
- Syntax
Error - A
SyntaxErroris thrown when the JavaScript engine encounters tokens or token order that does not conform to the syntax of the language when parsing code. - TryFrom
IntError - The error type returned when a checked integral type conversion fails.
- Type
Error - The
TypeErrorobject represents an error when a value is not of the expected type. - Uint8
Array - Uint8
Clamped Array - Uint16
Array - Uint32
Array - Undefined
- The JavaScript
undefinedvalue. - UriError
- The
URIErrorobject represents an error when a global URI handling function was used in a wrong way. - WeakMap
- WeakRef
- WeakSet
Traits§
- Async
Iterable - Trait for types known to implement the iterator protocol on Symbol.asyncIterator
- Function
Into Closure - Into
JsGeneric - Converts a value into its canonical JS-generic representation.
- Iterable
- Trait for JavaScript types that implement the iterable protocol via
Symbol.iterator. - JsArgs
- Trait for argument tuples that can call or bind a
Function<T>. - JsFunction
- JsFunction1
- JsFunction2
- JsFunction3
- JsFunction4
- JsFunction5
- JsFunction6
- JsFunction7
- JsFunction8
- JsGeneric
- Convenience bound for JS values whose generic parameters erase to
JsValue. - JsTuple
- Base trait for tuple types.
- JsTuple1
- JsTuple2
- JsTuple3
- JsTuple4
- JsTuple5
- JsTuple6
- JsTuple7
- JsTuple8
- Promising
- Marker trait for values that are either a resolution value or a promise-like value.
- Typed
Array
Functions§
- decode_
uri - decode_
uri_ component - encode_
uri - encode_
uri_ component - escape
- eval
- global
- Returns a handle to the global scope object.
- is_
finite - parse_
float - parse_
int - try_
iter - Create an iterator over
valusing the JS iteration protocol andSymbol.iterator. - unescape
Attribute Macros§
- wasm_
bindgen - The main wasm_bindgen attribute macro.