orbis_plugin_api/sdk/
mod.rs

1//! Orbis Plugin SDK
2//!
3//! This module provides a complete, ergonomic SDK for building WASM plugins with minimal boilerplate.
4//!
5//! # Quick Start
6//!
7//! ```rust,ignore
8//! use orbis_plugin_api::prelude::*;
9//!
10//! // Define your plugin using the macro
11//! orbis_plugin! {
12//!     name: "my-plugin",
13//!     version: "1.0.0",
14//!
15//!     // Optional initialization
16//!     init: || {
17//!         log::info!("Plugin initialized!");
18//!         Ok(())
19//!     },
20//!
21//!     // Optional cleanup
22//!     cleanup: || {
23//!         log::info!("Plugin cleaning up!");
24//!         Ok(())
25//!     },
26//!
27//!     handlers: {
28//!         "my_handler" => my_handler,
29//!     }
30//! }
31//!
32//! fn my_handler(ctx: Context) -> Result<Response> {
33//!     let count: i64 = state::get("counter")?.unwrap_or(0);
34//!     state::set("counter", &(count + 1))?;
35//!
36//!     Response::json(&json!({
37//!         "message": "Hello!",
38//!         "count": count + 1
39//!     }))
40//! }
41//! ```
42//!
43//! # Features
44//!
45//! - **Zero boilerplate**: No manual memory management, extern declarations, or FFI
46//! - **Type-safe state**: Automatic JSON serialization/deserialization
47//! - **Ergonomic logging**: Simple `log::info!()` style macros
48//! - **Database access**: Query and execute SQL with typed results
49//! - **HTTP client**: Make external API calls
50//! - **Event system**: Emit and subscribe to events
51//! - **Error handling**: Proper Result types with context
52
53pub mod context;
54pub mod db;
55pub mod error;
56pub mod ffi;
57pub mod http;
58pub mod log;
59pub mod response;
60pub mod state;
61
62// Re-export everything for convenience
63pub use context::Context;
64pub use db::{DbRow, DbValue};
65pub use error::{Error, Result};
66pub use response::Response;
67
68/// Prelude module for convenient imports
69pub mod prelude {
70    pub use super::context::Context;
71    pub use super::db::{self, DbRow, DbValue};
72    pub use super::error::{Error, Result};
73    pub use super::ffi::*;
74    pub use super::http;
75    pub use super::log;
76    pub use super::response::Response;
77    pub use super::state;
78
79    // Re-export serde for convenience
80    pub use serde::{Deserialize, Serialize};
81    pub use serde_json::{json, Value as JsonValue};
82}