crate_plugin_kit/loader/mod.rs
1//! Generic `dlopen` loading.
2//!
3//! # No type erasure here
4//!
5//! `T` is the host's own `#[repr(C)]` entry struct (for bmux, that is
6//! `BmuxPluginV1`). `load()` returns a `*const T` — a thin pointer, not a `dyn Trait`
7//! — so there is no "convert a fat pointer between two different vtables" UB.
8//!
9//! This crate neither knows nor needs to know which fields `T` has; it only reads
10//! the symbol address and casts it to `*const T`. Reading those fields safely is the
11//! host contract crate's job.
12//!
13//! # What the caller has to guarantee
14//!
15//! 1. `T` and the struct the plugin actually exports have the same layout (backed by
16//! the host's `abi_version` field);
17//! 2. every read of a field of `T` is wrapped in [`crate::panic::guard`].
18//!
19//! # Layout
20//!
21//! `open` holds the `dlopen` itself, `naming` decides which file names a cdylib can
22//! have. The two are independent on purpose: `pack` and `prebuilt` name artifacts for a
23//! target triple without ever loading anything.
24
25mod naming;
26mod open;
27
28pub use naming::{
29 find_library, find_library_for_target, lib_ext_for_target, library_candidates,
30 library_candidates_for_target,
31};
32pub use open::{open, LoadedPlugin};