1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//! Hooks for responding to hard-abort and reinit events on the Wasm instance.
//!
//! # Hard abort
//!
//! A hard abort occurs when the WebAssembly instance encounters a
//! non-recoverable error — an `unreachable` instruction, out-of-memory, or
//! stack overflow — that cannot be caught by Rust's `catch_unwind`. The
//! instance is poisoned and no further exports can be called.
//!
//! Use [`set_on_abort`] to register a callback that runs at the moment of
//! termination. Returns the previously registered handler (`None` if unset),
//! mirroring the `std::panic::set_hook` convention.
//!
//! **Experimental — only available when built with `panic=unwind`.**
//! [`set_on_abort`] returns `None` and the callback will never fire on
//! `panic=abort` builds.
//!
//! # Reinit
//!
//! [`reinit()`] writes a sentinel value (`0xFFFFFFFF`) into the termination
//! flag. The next call to any export detects this, creates a fresh
//! `WebAssembly.Instance` from the same module, and then calls
//! [`set_on_reinit`]'s callback (if any) on the new instance.
//!
//! Use [`set_on_reinit`] to register a reinit callback; it likewise returns
//! the previously registered handler.
//!
//! **Experimental — only available when built with `panic=unwind` and when
//! wasm-bindgen is invoked with `--experimental-reset-state-function`.**
//! Without that flag the JS-side guard that detects the sentinel is not
//! emitted, so calling [`reinit()`] writes the sentinel but it is never acted
//! upon. [`reinit()`] and [`set_on_reinit`] are no-ops on `panic=abort`
//! builds.
pub use cratereinit;
pub use crateset_on_abort;
pub use crateset_on_reinit;