Expand description
The plugin side of the ABI: everything between export!’s shims and the trait a plugin writes.
This is the only module in the crate that touches raw memory. It owns three jobs:
- Answer the host’s questions through the accessors (
dispatchis whatexport!points thecommandcapability at), - Build the typed
Contextout of them, so a plugin never sees a key or a pointer, - Hand the answer back in the ABI’s shape, with the memory this side owns.
Everything here runs inside the plugin, on data the host lent it. The rules it obeys:
- Nothing lent may be kept past the call.
- Memory is freed by the side that allocated it: what this module leases out for the answer is
reclaimed by
free_command/free_str, never by the host. - A panic must not cross: the shims in
export!wrap every entry point incatch_unwind.
Constants§
- BUILD_
RUSTC - The rustc version this crate was built with, injected by
build.rs. Diagnostics only. - BUILD_
TARGET - The target this crate was built for, injected by
build.rs. Diagnostics only. - PANIC_
MARKER - What
name/familyanswer when the plugin panicked before it could answer at all.
Functions§
- dispatch⚠
- The plugin-side entry point
export!exposes as thecommandcapability. - dispatch_
free_ ⚠command - The
free_commandshim’s implementation. - dispatch_
free_ ⚠str - The
free_strshim’s implementation. - free_
command ⚠ - Release everything
write_commandallocated, without touching the struct itself (it lives on the host’s stack). - free_
str ⚠ - Give one string back to this side’s allocator.
- guard
- Wrap one cross-boundary call in
catch_unwind. - guard_
str - The same, for one of the two
-> PmpxStrshims. - install_
log_ ⚠table - Install the host’s logging table, after the caller has checked its size.
- leak_
bytes - Lease out bytes for the host to read.
- leak_
str - Lease out text for the host to read.
- read_os⚠
- Read a borrowed C string as an owned
OsString, losslessly where the platform allows it. - read_
str ⚠ - Read a borrowed C string as text, checking UTF-8.
- remember_
name - Remember the plugin’s own name, for the no-host fallback.
- write_
command ⚠ - Write a
CommandSpecin its cross-boundary form, with the memory allocated by this side.