webarcade_api/
lib.rs

1//! # WebArcade Plugin API (Lightweight)
2//!
3//! Minimal API for building WebArcade plugins with fast compile times.
4//! This crate provides only what's needed for FFI plugin communication.
5//!
6//! ## Features
7//!
8//! - `bridge` - Enable HTTP bridge functionality (tokio, http types). Only needed
9//!   for plugins that define routes in their Cargo.toml.
10//!
11//! ## Quick Start
12//!
13//! ```rust
14//! use api::prelude::*;
15//!
16//! pub struct MyPlugin;
17//!
18//! impl Plugin for MyPlugin {
19//!     fn metadata(&self) -> PluginMetadata {
20//!         PluginMetadata {
21//!             id: "my-plugin".into(),
22//!             name: "My Plugin".into(),
23//!             version: "1.0.0".into(),
24//!             description: "A plugin".into(),
25//!             author: "You".into(),
26//!             dependencies: vec![],
27//!         }
28//!     }
29//! }
30//! ```
31
32// Core modules (always available)
33pub mod plugin;
34
35// Bridge modules (only with "bridge" feature)
36#[cfg(feature = "bridge")]
37pub mod http;
38#[cfg(feature = "bridge")]
39pub mod ffi_http;
40
41// Re-export core types (always available)
42pub use plugin::{Plugin, PluginMetadata};
43
44// Re-export bridge types (only with "bridge" feature)
45#[cfg(feature = "bridge")]
46pub use http::{HttpRequest, HttpResponse, MultipartField, json_response, error_response};
47#[cfg(feature = "bridge")]
48pub use ffi_http::{Request as FfiRequest, Response as FfiResponse};
49
50// Backward compatibility aliases (only with "bridge" feature)
51#[cfg(feature = "bridge")]
52pub use http::HttpRequest as Request;
53#[cfg(feature = "bridge")]
54pub use http::HttpResponse as Response;
55
56// Re-export dependencies for use in generated code
57pub use serde::{Serialize, Deserialize};
58pub use serde_json::{self, json, Value};
59pub use log;
60
61// Bridge-only re-exports
62#[cfg(feature = "bridge")]
63pub use base64;
64#[cfg(feature = "bridge")]
65pub use tokio;
66#[cfg(feature = "bridge")]
67pub use bytes::Bytes;
68
69// Prelude for convenient imports
70pub mod prelude {
71    pub use crate::plugin::{Plugin, PluginMetadata};
72    pub use serde::{Serialize, Deserialize};
73    pub use serde_json::{json, Value};
74
75    // Bridge types in prelude (only with "bridge" feature)
76    #[cfg(feature = "bridge")]
77    pub use crate::http::{HttpRequest, HttpResponse, MultipartField, json_response, error_response};
78    #[cfg(feature = "bridge")]
79    pub use crate::ffi_http::{Request as FfiRequest, Response as FfiResponse};
80}