rustledger_plugin/lib.rs
1//! Beancount WASM Plugin Runtime.
2//!
3//! This crate provides a plugin system for extending Beancount's functionality.
4//! Plugins can be written in any language that compiles to WebAssembly, or as
5//! native Rust code for maximum performance.
6//!
7//! # Architecture
8//!
9//! The plugin system uses wasmtime as the WASM runtime with `MessagePack`
10//! serialization for passing data across the WASM boundary.
11//!
12//! # Plugin Types
13//!
14//! - **WASM Plugins**: Sandboxed plugins loaded from `.wasm` files
15//! - **Native Plugins**: Built-in plugins implemented in Rust
16//!
17//! # Built-in Plugins (30)
18//!
19//! See the [plugin reference](https://rustledger.github.io/docs/reference/plugins) for the full list.
20//!
21//! # Example
22//!
23//! ```ignore
24//! use rustledger_plugin::{PluginManager, PluginInput, PluginOptions};
25//!
26//! let mut manager = PluginManager::new();
27//! manager.load(Path::new("my_plugin.wasm"))?;
28//!
29//! let input = PluginInput {
30//! directives: vec![],
31//! options: PluginOptions::default(),
32//! config: None,
33//! };
34//!
35//! let output = manager.execute_all(input)?;
36//! ```
37
38// Note: unsafe is needed for wasmtime Module::deserialize (caching compiled modules)
39#![deny(unsafe_code)]
40#![warn(missing_docs)]
41
42pub mod convert;
43pub mod native;
44#[cfg(feature = "python-plugins")]
45pub mod python;
46#[cfg(feature = "wasm-runtime")]
47pub mod runtime;
48pub mod types;
49
50pub use convert::{
51 ConversionError, directive_to_wrapper, directive_to_wrapper_with_location,
52 directives_to_wrappers, wrapper_to_directive, wrappers_to_directives,
53};
54pub use native::{DocumentDiscoveryPlugin, NativePlugin, NativePluginRegistry};
55#[cfg(feature = "wasm-runtime")]
56pub use runtime::{
57 Plugin, PluginManager, RuntimeConfig, WatchingPluginManager, validate_plugin_module,
58};
59pub use types::{PluginError, PluginErrorSeverity, PluginInput, PluginOptions, PluginOutput};