Skip to main content

Crate samp_codegen

Crate samp_codegen 

Source
Expand description

Proc macros for the rust-samp toolkit.

  • #[native] — generates the extern "C" FFI wrapper for a Rust function, parsing arguments via AmxCell and handling the return value.
  • initialize_plugin! — generates the entry points required by the server (Supports/Load/Unload/AmxLoad/AmxUnload/ProcessTick on SA-MP and ComponentEntryPoint + vtable on Open Multiplayer), as well as native registration.
  • #[derive(SampPlugin)] — shortcut for an empty impl SampPlugin for T {}.

This crate only compiles when loaded by samp via reexport — it has no runtime API of its own.

Macros§

initialize_plugin
Generates the entry points required by the server (SA-MP + Open Multiplayer), the Rust IComponent vtable and the registration of the plugin’s native list.

Attribute Macros§

native
Generates the extern "C" wrapper that reads the AMX argument table, parses it into the Rust types declared in the signature and invokes the marked method.

Derive Macros§

SampPlugin
Generates impl SampPlugin for T {} with all methods using the default behavior (empty). Use for structs that do not need to customize any lifecycle callback — write the impl SampPlugin manually when some method needs custom logic.