Skip to main content

wry_bindgen_runtime/
lib.rs

1#![doc = include_str!("../README.md")]
2#![no_std]
3
4extern crate alloc;
5#[macro_use]
6extern crate std;
7
8mod batch;
9mod function_registry;
10mod id_allocator;
11mod ipc;
12mod js_helpers;
13mod runtime;
14mod type_cache;
15mod wry;
16
17/// The unstable runtime seam: the wire vocabulary (binary encode/decode, the
18/// opaque value/object handles, the IPC buffers, the generated-code
19/// registration specs) plus the runtime handle, its accessor, the batching
20/// controls, and the synchronous call primitive that drive it.
21///
22/// **Unstable.** Published for `wry-bindgen-core` (which wraps it in a stable,
23/// semantic boundary) and `wry-launch` (the host event-loop integration).
24/// Nothing here is covered by semver — application code should depend on
25/// `wry-bindgen-core` instead.
26#[doc(hidden)]
27pub mod wire;
28
29pub use wry::{
30    ProtocolHandler, WryBindgen, WryBindgenDriver, WryBindgenRuntime, WryBindgenWebviewDriver,
31};
32
33mod encode {
34    pub(crate) use crate::wire::BinaryDecode;
35}
36
37mod function {
38    pub(crate) const DROP_NATIVE_REF_FN_ID: u32 = 0xFFFF_FFFF;
39    pub(crate) const CALL_EXPORT_FN_ID: u32 = 0xFFFF_FFFE;
40    pub(crate) use crate::wire::RustCallback;
41}
42
43mod object_store {
44    use alloc::boxed::Box;
45    use core::any::Any;
46
47    pub(crate) use crate::wire::ObjectHandle;
48
49    pub(crate) fn drop_object(handle: ObjectHandle) -> bool {
50        let object: Option<Box<dyn Any>> =
51            crate::batch::with_runtime(|state| state.drop_object_handle(handle));
52        let dropped = object.is_some();
53        drop(object);
54        dropped
55    }
56}
57
58mod value {
59    pub(crate) const JSIDX_OFFSET: u64 = 128;
60    pub(crate) const JSIDX_RESERVED: u64 = JSIDX_OFFSET + 4;
61}