Expand description
§dyn-loader
Dynamic library loader with dyn-fat-pointer-bridge for loading trait objects
from .so/.dylib plugin files.
Architecture (adapted from my-agent’s plugin-loader + safe-arc + rust-plugin-loader):
- DynLib: Wraps
libloading::LibrarywithArcfor shared ownership. - AbiDynFatPtr: ABI-stable representation of a Rust fat pointer
(data ptr + vtable ptr),
#[repr(C)]for C ABI compatibility. - AbiStableDynRef: Fat pointer + retain/release function pointers, enabling safe cross-boundary Arc-like reference counting.
- DynPlugin
: Loaded plugin holding a SafeArcDyn<T>that can be dereferenced to&Tto call trait methods on the loaded object.
§Usage
ⓘ
// 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:
let plugin = DynPlugin::<dyn Transform>::load("libmy_transform.so", b"core_ast_transform_entry\0")?;
let transform: &dyn Transform = plugin.as_ref();Structs§
- AbiDyn
FatPtr - ABI-stable representation of a Rust dyn trait fat pointer. Two words: data pointer + vtable pointer.
- AbiStable
DynRef - ABI-stable reference to a dyn trait object, with retain/release for safe reference counting across dynamic library boundaries.
- DynLib
- DynPlugin
- A loaded dynamic library plugin that exposes a trait object via the dyn-fat-pointer-bridge pattern.
- Generated
Function - Descriptor for a generated math function (matches C++ GeneratedFunction)
- Math
Module Vtable - Vtable struct matching C++ MathModuleVtable layout exactly
- Safe
ArcDyn - A safe, cloneable, droppable reference to a dyn trait object loaded from a dynamic library. Uses Arc-like retain/release for memory safety.
- VTable
Plugin - Load a Copy-sized vtable/descriptor struct from a dynamic library.
Functions§
- looks_
like_ ⚠plugin - Quick check: does the file look like a plugin with the given entry symbol?
- pack_
fat_ ⚠ptr - Pack a
*const T(where T: ?Sized) into an ABI-stable fat pointer. - unpack_
fat_ ⚠ptr - Unpack an ABI-stable fat pointer back to
*const T.
Type Aliases§
- Math
Session - Opaque handle for a C++ MathSession
- Plugin
Entry Point - Type of the entry point function that plugins must export.
- Release
Fn - Retain
Fn