anvil-sys 1.15.0

Raw bindings to the Anvil plugin API 2 (anvil_plugin.h), 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, the native plugin loader for Europa Universalis IV 1.37.5 (include/anvil/anvil_plugin.h). no_std, no dependencies.

  • src/bindings.rs is generated by bindgen from the header and committed. CI regenerates it and fails when it differs (sdk/rust/regen-bindings.ps1).
  • 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 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. examples/hello-rust in the Anvil repository is a complete plugin; 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 header it binds. A safe anvil crate on top of it is planned.

License: MIT.