Expand description
Orbis Plugin SDK
This module provides a complete, ergonomic SDK for building WASM plugins with minimal boilerplate.
§Quick Start
ⓘ
use orbis_plugin_api::prelude::*;
// Define your plugin using the macro
orbis_plugin! {
name: "my-plugin",
version: "1.0.0",
// Optional initialization
init: || {
log::info!("Plugin initialized!");
Ok(())
},
// Optional cleanup
cleanup: || {
log::info!("Plugin cleaning up!");
Ok(())
},
handlers: {
"my_handler" => my_handler,
}
}
fn my_handler(ctx: Context) -> Result<Response> {
let count: i64 = state::get("counter")?.unwrap_or(0);
state::set("counter", &(count + 1))?;
Response::json(&json!({
"message": "Hello!",
"count": count + 1
}))
}§Features
- Zero boilerplate: No manual memory management, extern declarations, or FFI
- Type-safe state: Automatic JSON serialization/deserialization
- Ergonomic logging: Simple
log::info!()style macros - Database access: Query and execute SQL with typed results
- HTTP client: Make external API calls
- Event system: Emit and subscribe to events
- Error handling: Proper Result types with context
Re-exports§
pub use context::Context;pub use db::DbRow;pub use db::DbValue;pub use error::Error;pub use error::Result;pub use response::Response;
Modules§
- context
- Request context passed to plugin handlers.
- db
- Database access for plugins.
- error
- Plugin SDK error types.
- ffi
- FFI declarations and memory management.
- http
- HTTP client for making external requests.
- log
- Logging utilities for plugins.
- prelude
- Prelude module for convenient imports
- response
- Response builder for plugin handlers.
- state
- Type-safe state management for plugins.