Skip to main content

BundleBuilder

Struct BundleBuilder 

Source
pub struct BundleBuilder { /* private fields */ }
Expand description

Builder for creating plugin bundles.

§Example

use rustbridge_bundle::{BundleBuilder, Manifest, Platform};

let manifest = Manifest::new("my-plugin", "1.0.0");
let builder = BundleBuilder::new(manifest)
    .add_library(Platform::LinuxX86_64, "target/release/libmyplugin.so")?
    .add_schema_file("schema/messages.h", "include/messages.h")?;

builder.write("my-plugin-1.0.0.rbp")?;

Implementations§

Source§

impl BundleBuilder

Source

pub fn new(manifest: Manifest) -> Self

Create a new bundle builder with the given manifest.

Source

pub fn with_signing_key( self, public_key_base64: String, secret_key: SecretKey, ) -> Self

Set the signing key for bundle signing.

The secret key will be used to sign all library files and the manifest. The corresponding public key will be embedded in the manifest.

§Arguments
  • public_key_base64 - The public key in base64 format (from the .pub file)
  • secret_key - The secret key for signing
Source

pub fn add_library<P: AsRef<Path>>( self, platform: Platform, library_path: P, ) -> BundleResult<Self>

Add a platform-specific library to the bundle as the release variant.

This reads the library file, computes its SHA256 checksum, and updates the manifest with the platform information.

This is a convenience method that adds the library as the release variant. For other variants, use add_library_variant instead.

Source

pub fn add_library_variant<P: AsRef<Path>>( self, platform: Platform, variant: &str, library_path: P, ) -> BundleResult<Self>

Add a variant-specific library to the bundle.

This reads the library file, computes its SHA256 checksum, and updates the manifest with the platform and variant information.

§Arguments
  • platform - Target platform
  • variant - Variant name (e.g., “release”, “debug”)
  • library_path - Path to the library file
Source

pub fn add_library_variant_with_build<P: AsRef<Path>>( self, platform: Platform, variant: &str, library_path: P, build: Value, ) -> BundleResult<Self>

Add a variant-specific library with build metadata.

Similar to add_library_variant but also attaches build metadata to the variant (e.g., compiler flags, features, etc.).

Source

pub fn add_schema_file<P: AsRef<Path>>( self, source_path: P, archive_name: &str, ) -> BundleResult<Self>

Add a schema file to the bundle.

Schema files are stored in the schema/ directory within the bundle.

The schema format is automatically detected from the file extension:

  • .h -> “c-header”
  • .json -> “json-schema”
  • Others -> “unknown”
Source

pub fn add_doc_file<P: AsRef<Path>>( self, source_path: P, archive_name: &str, ) -> BundleResult<Self>

Add a documentation file to the bundle.

Documentation files are stored in the docs/ directory within the bundle.

Source

pub fn add_bytes(self, archive_path: &str, contents: Vec<u8>) -> Self

Add raw bytes as a file in the bundle.

Source

pub fn with_build_info(self, build_info: BuildInfo) -> Self

Set the build information for the bundle.

Source

pub fn with_sbom(self, sbom: Sbom) -> Self

Set the SBOM paths.

Source

pub fn add_notices_file<P: AsRef<Path>>( self, source_path: P, ) -> BundleResult<Self>

Add a notices file to the bundle.

The file will be stored in the docs/ directory.

Source

pub fn add_license_file<P: AsRef<Path>>( self, source_path: P, ) -> BundleResult<Self>

Add the plugin’s license file to the bundle.

The file will be stored in the legal/ directory as LICENSE. This is for the plugin’s own license, not third-party notices.

Source

pub fn add_sbom_file<P: AsRef<Path>>( self, source_path: P, archive_name: &str, ) -> BundleResult<Self>

Add an SBOM file to the bundle.

The file will be stored in the sbom/ directory.

Source

pub fn write<P: AsRef<Path>>(self, output_path: P) -> BundleResult<()>

Write the bundle to a file.

Source

pub fn set_variant_build_info( &mut self, platform: Platform, variant: &str, build_info: BuildInfo, ) -> BundleResult<()>

Set variant-level build info (v1.1).

The variant must already exist for the given platform.

Source

pub fn set_variant_sbom( &mut self, platform: Platform, variant: &str, sbom: Sbom, ) -> BundleResult<()>

Set variant-level SBOM (v1.1).

Source

pub fn set_variant_schema_checksum( &mut self, platform: Platform, variant: &str, checksum: String, ) -> BundleResult<()>

Set variant-level schema checksum (v1.1).

Source

pub fn set_variant_schemas( &mut self, platform: Platform, variant: &str, schemas: HashMap<String, SchemaInfo>, ) -> BundleResult<()>

Set variant-level schemas (v1.1).

Source

pub fn manifest(&self) -> &Manifest

Get the current manifest (for inspection).

Source

pub fn manifest_mut(&mut self) -> &mut Manifest

Get a mutable reference to the manifest (for modification).

Trait Implementations§

Source§

impl Debug for BundleBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.