anvil-sys 1.18.0

Raw bindings to the Anvil plugin API 2 and its services, the C ABI of the Anvil plugin loader for Europa Universalis IV
Documentation
# anvil-sys

Raw Rust bindings to the plugin API 2 of [Anvil](https://github.com/happy-dwarf-team/anvil),
the native plugin loader for Europa Universalis IV 1.37.5 (`include/anvil/anvil_plugin.h`),
and to the services Anvil ships: `anvil-game.game` and `anvil-game.world`
(`anvil_game.h`), `anvil-overlay.panel` (`anvil_panel.h`), `anvil-overlay.input` (`anvil_input.h`) and `anvil.benchmark`
(`anvil_benchmark.h`). `no_std`, no dependencies.

Most plugins want the safe crate on top of it,
[`anvil-sdk`](https://crates.io/crates/anvil-sdk) (library `anvil`).

- `src/bindings.rs` is generated by `bindgen` from the headers and committed. CI
  regenerates it and fails when it differs (`sdk/rust/regen-bindings.ps1`).
- A service table is `#[repr(C)]` with `Option<unsafe extern "C" fn>` fields;
  the `ANVIL_*_HAS` macros are C, so compare `size` with `offset_of!` before
  using a function appended after the service's first release.
- `AnvilCpuContext` is `#[repr(C)]`, 408 bytes (checked at compile time).
- C enums are plain integer constants (`AnvilResult`, `ANVIL_OK`, …): a value
  from the host never becomes an invalid Rust enum.
- `AnvilPluginLoadFn` is the type of `anvil_plugin_load`, the one function a
  plugin exports. The crate declares no extern functions.

A plugin on the raw API is a `cdylib` that exports `anvil_plugin_load` and
returns an `AnvilResult`. Catch panics at every function the game or Anvil
calls: unwinding into them aborts the process. `anvil gen --lang rust` writes
the typed symbols (`symbols.gen.rs`) from the plugin's `symbols.toml`.

The version of this crate is the version of Anvil whose headers it binds.

License: MIT.