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
//! # dyn-loader
//!
//! Dynamic library loader with two plugin-loading modes:
//!
//! ## [`dyn`] — Rust fat-pointer bridge (trait objects)
//!
//! Load Rust trait objects from `.so`/`.dylib` plugins via their native
//! fat-pointer representation (data + vtable), with Arc-like retain/release
//! for cross-boundary memory safety.
//!
//! ```ignore
//! // In the plugin .so:
//! #[no_mangle]
//! pub extern "C" fn core_ast_transform_entry() -> AbiStableDynRef {
//! SafeArcDyn::from_arc(Arc::new(MyTransform) as Arc<dyn Transform>).into_abi()
//! }
//!
//! // In the host:
//! use dyn_loader::dyn::{DynPlugin, AbiStableDynRef};
//! let plugin = DynPlugin::<dyn Transform>::load("libmy_transform.so", b"core_ast_transform_entry\0")?;
//! let transform: &dyn Transform = plugin.trait_ref();
//! ```
//!
//! ## [`cdyn`] — COM-style C function tables (ABI-stable)
//!
//! Load plain C function-table structs (`#[repr(C)]` Copy types) via
//! positional dispatch — no trait objects, stable across languages and
//! (to a large extent) compiler versions. This is the former `cdyn-loader`
//! crate, merged here as `VTablePlugin<T>`.
//!
//! ```ignore
//! let plugin = unsafe { VTablePlugin::<MyVtable>::load("libmy.so", b"my_get_vtable\0")? };
//! ```
//!
//! ## ⚠️ ABI compatibility / compiler version alignment
//!
//! Even though [`cdyn`] mode is layout-stable, the Rust compiler version must
//! still be strictly aligned across all libraries and executables that
//! exchange pointers across the boundary. Pin one toolchain (e.g. via
//! `rust-toolchain.toml`) and rebuild everything together. See the README for
//! the full cross-version compatibility matrix.
pub use ;
pub use ;
pub use ;