Skip to main content

Crate pmpx_loader

Crate pmpx_loader 

Source
Expand description

The host side of the plugin ABI: load a library, agree on capabilities, call it.

This crate is the only place in the host that touches plugin memory, and together with pmpx-plugin-abi it is the only place that contains unsafe at all. Everything above it (pmpx-engine, the CLI) works with String, PathBuf and Vec<OsString>.

What it deliberately does not do:

  • No file I/O. A plugin may ask for the contents of a file it declared; this crate forwards that question to a ContextSource’s Files provider, and the engine answers it (reading files, with whatever limits it wants, is the engine’s decision). That is what keeps the ABI layer free of file-system policy.
  • No policy. It does not decide which plugin to load, what a verb means, or whether an empty program is acceptable. It loads, checks, calls, and reports what came back.
  • No printing. Every failure is a typed error with a message; the CLI renders it.

§Calling one plugin

use pmpx_loader::{ContextSource, Plugin};
// SAFETY: loading a dynamic library runs whatever code is inside it.
let plugin = unsafe { Plugin::open(std::path::Path::new("/path/to/libpmpx_plugin_x.so"))? };
println!("{} ({})", plugin.name(), plugin.family());

§Panics

A panic must not cross an extern "C" boundary: since Rust 1.81 that aborts the process at the boundary, so a host frame can never catch it. The plugin’s own shell wraps every entry point in catch_unwind, and that is the only defence there is – a host that must survive a hostile plugin has to run it out of process, which is out of scope here.

Structs§

Command
One command a plugin answered with.
ContextSource
Everything the host can answer for one call.
NoFiles
A provider with nothing to offer: what a host that does not implement [context] files uses.
Plugin
A loaded plugin: the library stays open, and every function pointer in its tables belongs to it.
Tables
The tables of one plugin, checked and ready to call.

Enums§

CallError
What one call to a plugin came back with.
LoadError
A plugin could not be loaded, or does not speak this ABI.

Traits§

Files
Where the contents of a declared file come from.