openstranded_plugin_api/lib.rs
1//! # openstranded-plugin-api
2//!
3//! Plugin SDK for `OpenStranded` — the core types and traits that all
4//! WASM game plugins use to communicate with the engine and each other.
5//!
6//! ## Core types
7//!
8//! - [`Value`]: dynamic type for cross-plugin arguments and return values
9//! - [`ServiceError`]: typed errors for Service API calls
10//! - [`Service`] + [`ServiceRegistry`]: cross-plugin method call interface
11//! - [`Registry`] + [`RegistryEntry`]: in-memory content pack data
12//! - [`GameAPI`]: host-side API surface provided to plugins
13//! - [`Contribution`]: declarative output from WASM plugin `build()` phase
14//! - [`ApiVersion`]: compile-time baked version for compatibility checks
15//!
16//! ## Feature flags
17//!
18//! - `ron` (default): enables [`parse_registry_data`] and [`parse_registry_list`]
19//! - `test-utils`: enables `MockGameAPI` for testing
20//!
21//! ## WASM entry points
22//!
23//! Every WASM plugin must export the following `#[no_mangle] extern "C"` functions:
24//!
25//! | Export | Required | Called during |
26//! |--------|----------|---------------|
27//! | `plugin_api_version() -> ApiVersion` | Yes | Load, before anything |
28//! | `plugin_build(ctx) -> Vec<Contribution>` | Yes | Registry phase |
29//! | `plugin_ready(api) -> bool` | No | Discovery phase |
30//! | `plugin_finish(api)` | No | Integration phase |
31
32mod value;
33mod error;
34mod service;
35mod registry;
36mod game_api;
37mod contributions;
38mod version;
39
40#[cfg(feature = "test-utils")]
41pub mod test_utils;
42
43// ── Re-exports ─────────────────────────────────────────────────────
44
45pub use value::Value;
46pub use error::ServiceError;
47pub use service::{Service, ServiceRegistry};
48pub use registry::{Registry, RegistryEntry};
49#[cfg(feature = "ron")]
50pub use registry::{parse_registry_data, parse_registry_list};
51pub use game_api::{GameAPI, LogLevel};
52pub use contributions::{Contribution, SystemDecl, ResourceDecl};
53pub use version::{ApiVersion, VersionMismatch};