Skip to main content

rustbridge_bundle/
lib.rs

1//! Plugin bundle format for rustbridge
2//!
3//! This crate provides types and utilities for creating and loading `.rbp`
4//! (rustbridge plugin) bundles - standardized archives containing multi-platform
5//! plugin libraries and metadata.
6//!
7//! # Bundle Structure
8//!
9//! ```text
10//! my-plugin-1.0.0.rbp
11//! ├── manifest.json
12//! ├── schema/
13//! │   ├── messages.json          # JSON Schema for message types
14//! │   └── messages.h             # C header with struct definitions
15//! ├── lib/
16//! │   ├── linux-x86_64/
17//! │   │   └── libmyplugin.so
18//! │   ├── darwin-aarch64/
19//! │   │   └── libmyplugin.dylib
20//! │   └── windows-x86_64/
21//! │       └── myplugin.dll
22//! └── docs/
23//!     └── README.md
24//! ```
25//!
26//! # Example
27//!
28//! ```no_run
29//! use rustbridge_bundle::{BundleBuilder, Manifest, Platform};
30//!
31//! // Create a bundle
32//! let manifest = Manifest::new("my-plugin", "1.0.0");
33//! let builder = BundleBuilder::new(manifest)
34//!     .add_library(Platform::LinuxX86_64, "target/release/libmyplugin.so")?
35//!     .add_library(Platform::DarwinAarch64, "target/release/libmyplugin.dylib")?;
36//!
37//! builder.write("my-plugin-1.0.0.rbp")?;
38//! # Ok::<(), rustbridge_bundle::BundleError>(())
39//! ```
40
41mod error;
42mod manifest;
43mod platform;
44
45pub mod builder;
46pub mod loader;
47
48pub use builder::BundleBuilder;
49pub use error::BundleError;
50pub use loader::BundleLoader;
51pub use manifest::{
52    BuildInfo, GitInfo, Manifest, PlatformInfo, PluginInfo, Sbom, SchemaInfo, VariantInfo,
53};
54pub use platform::Platform;
55
56/// Result type for bundle operations.
57pub type BundleResult<T> = Result<T, BundleError>;
58
59/// Bundle file extension.
60pub const BUNDLE_EXTENSION: &str = "rbp";
61
62/// Current bundle format version.
63pub const BUNDLE_VERSION: &str = "1.0";
64
65/// Bundle format version 1.1 (variant-level metadata).
66pub const BUNDLE_VERSION_1_1: &str = "1.1";
67
68/// Manifest file name within the bundle.
69pub const MANIFEST_FILE: &str = "manifest.json";