pmpx-plugin
The contract a plugin author implements
The contract a plugin author implements: the PackageManager trait and the shell that carries it safely across the dlopen boundary. A plugin crate is a plain rlib whose pub fn create() -> Box<dyn PackageManager> is the entry point the generated wrapper calls. The crate has no feature flags, depends only on pmpx-plugin-abi, and keeps rust-version = "1.82" because that MSRV decides who can write a plugin.
API
PackageManager— implementname,familyandcommand.Context<'a>—project_root,start_dir,matched,config_files,pins,reason,score, and the methodshas_matched,was_pinned,pinned_for,file,file_str.CommandSpec—new(program),arg,args,cwd, with the publicprogram,argsandcwdfields.Verb— the closed setInstall,Remove,Update,Run,Build,Test,Exec, withALL,to_abi,from_abiandas_str.Family— an open string type with the constantsNODE,RUST,PYTHON,GO,JVM,DOTNET,PHP,RUBYandnew(name).PluginError—UnsupportedVerb,InvalidArgs,Other, withunsupported_verb,invalid_args,other,code()andmessage().debug!/info!/warn!/error!— the logging macros, plus thedebugmodule (Level,wants,emit,context).export!,shellandabi— the macro that generates the ABI, the plugin-side helpers (dispatch,guard,PANIC_MARKER,BUILD_RUSTC,BUILD_TARGET) and the wire format.
Notes
export!goes in the wrapper crate that becomes the cdylib, not in the plugin crate: writing it in both definespmpx_plugin_entry_v3twice and fails at link time.command()is a pure mapping — no file reads, no environment, no child processes, no network; project contents arrive only throughContext::matchedand the declared[context] files, and an undeclared name is never readable.- A panic in
commandbecomesPMPX_ERR_INTERNALand one innameorfamilybecomesPANIC_MARKER; the trait is synchronous, with noasyncand no callbacks. - The crate requires
std(onlypmpx-plugin-abiisno_std), andContext::builder()builds a context by hand for a plugin's own tests.
Tests: cargo test -p pmpx-plugin — unit tests beside the code, plus tests/in_process.rs, tests/short_log_table.rs and tests/dlopen.rs, which builds tests/fixtures/toy-plugin into a cdylib and loads it.
License: same as the workspace (see the repository root).