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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//! # dyn-loader — standardized module loading protocol
//!
//! A **language-agnostic module loading protocol** built on the C ABI.
//! Not a "plugin system": any dynamic library (.so/.dll/.dylib) that follows
//! the protocol becomes a *module* that any host — in any language — can
//! load, call, share and release.
//!
//! ## Protocol boundary rule (first law)
//!
//! **Only standard C interfaces may cross the module boundary.** Legal
//! transports are: `extern "C"` functions, C scalar types, `#[repr(C)]` POD
//! structs, C strings, and function pointers. Language-runtime objects
//! (C++ exceptions, Zig error unions, Rust panics, GC references) must never
//! cross. The single controlled exception is the [`native`] fat-pointer
//! pair, valid only under the same-compiler-version clause.
//!
//! ## Ownership invariants
//!
//! 1. **Whoever allocates, deallocates** — every pointer crossing the
//! boundary is paired with a free/release function pointer belonging to
//! the allocating module.
//! 2. **Whoever creates, operates** — the host receives a calling convention
//! (vtable layout) plus function pointers; all operations execute inside
//! the creator's module.
//!
//! The only thing that ever crosses the boundary, in any language, is the
//! protocol itself: pointers plus function pointers.
//!
//! ## Layers
//!
//! - **[`abi`]** — the protocol standard layer: interface tables
//! ([`AbiTable<T>`]), ref-counted interface references
//! ([`AbiRef<T>`], [`AbiStableDynRef`]) and single-owner data boxes
//! ([`AbiBox`]). Pure C ABI, works from C/C++/Zig/anything.
//! - **[`native`]** — the Rust convenience layer: skip hand-written vtables
//! by exchanging native Rust fat pointers (`SafeArcDyn`, `NativeModule`).
//! Requires identical toolchain on both sides. Rust-to-Rust only.
//!
//! ## Module lifecycle
//!
//! ```ignore
//! // Host loads a module and its interface table:
//! let iface = unsafe { AbiTable::<MyInterface>::load("libmy.so", b"my_get_interface\0")? };
//! let sum = unsafe { (iface.get().add)(1, 2) };
//!
//! // Ref-counted module object (multi-owner):
//! let obj = unsafe { AbiRef::<MyInterface>::load(&path, b"my_get_dyn\0")? };
//!
//! // Single-owner data box (freed by the producer module):
//! let data = unsafe { AbiBoxHandle::load(&path, b"my_get_data\0")? };
//! ```
pub use ;
pub use ;
pub use ;