Skip to main content

BundleLoader

Struct BundleLoader 

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

Loader for plugin bundles.

§Example

use rustbridge_bundle::loader::BundleLoader;

let mut loader = BundleLoader::open("my-plugin-1.0.0.rbp")?;
let manifest = loader.manifest();

// Extract library for current platform to temp directory
let library_path = loader.extract_library_for_current_platform("/tmp/plugins")?;

Implementations§

Source§

impl BundleLoader

Source

pub fn open<P: AsRef<Path>>(path: P) -> BundleResult<Self>

Open a bundle file for reading.

Source

pub fn manifest(&self) -> &Manifest

Get the bundle manifest.

Source

pub fn supports_current_platform(&self) -> bool

Check if the bundle supports the current platform.

Source

pub fn current_platform_info(&self) -> Option<&PlatformInfo>

Get the platform info for the current platform.

Source

pub fn extract_library<P: AsRef<Path>>( &mut self, platform: Platform, output_dir: P, ) -> BundleResult<PathBuf>

Extract the library for a specific platform to a directory.

Extracts the release variant (default). For other variants, use extract_library_variant instead.

Returns the path to the extracted library file.

Source

pub fn extract_library_variant<P: AsRef<Path>>( &mut self, platform: Platform, variant: &str, output_dir: P, ) -> BundleResult<PathBuf>

Extract a specific variant of the library for a platform.

Returns the path to the extracted library file.

Source

pub fn list_variants(&self, platform: Platform) -> Vec<&str>

List all available variants for a platform.

Source

pub fn has_variant(&self, platform: Platform, variant: &str) -> bool

Check if a specific variant exists for a platform.

Source

pub fn build_info(&self) -> Option<&BuildInfo>

Get the build info from the manifest.

Source

pub fn sbom(&self) -> Option<&Sbom>

Get the SBOM info from the manifest.

Source

pub fn extract_library_for_current_platform<P: AsRef<Path>>( &mut self, output_dir: P, ) -> BundleResult<PathBuf>

Extract the library for the current platform to a directory.

Returns the path to the extracted library file.

Source

pub fn read_file(&mut self, path: &str) -> BundleResult<Vec<u8>>

Read a file from the bundle as bytes.

Source

pub fn read_file_string(&mut self, path: &str) -> BundleResult<String>

Read a file from the bundle as a string.

Source

pub fn list_files(&self) -> Vec<String>

List all files in the bundle.

Source

pub fn has_file(&self, path: &str) -> bool

Check if a file exists in the bundle.

Source

pub fn has_signatures(&self) -> bool

Check if the bundle has signature files.

Source

pub fn public_key(&self) -> Option<&str>

Get the public key from the manifest.

Source

pub fn verify_manifest_signature(&mut self) -> BundleResult<()>

Verify the manifest signature.

Returns Ok(()) if verification succeeds, or an error if it fails. If no public key is available, returns BundleError::NoPublicKey.

Source

pub fn verify_manifest_signature_with_key( &mut self, public_key_override: Option<&str>, ) -> BundleResult<()>

Verify the manifest signature with an optional key override.

§Arguments
  • public_key_override - If provided, use this key instead of the manifest’s key
Source

pub fn verify_library_signature( &mut self, library_path: &str, library_data: &[u8], ) -> BundleResult<()>

Verify a library signature.

§Arguments
  • library_path - Path to the library within the bundle
  • library_data - The library file contents
Source

pub fn verify_library_signature_with_key( &mut self, library_path: &str, library_data: &[u8], public_key_override: Option<&str>, ) -> BundleResult<()>

Verify a library signature with an optional key override.

Source

pub fn extract_library_verified<P: AsRef<Path>>( &mut self, platform: Platform, output_dir: P, verify_signature: bool, public_key_override: Option<&str>, ) -> BundleResult<PathBuf>

Extract and verify a library for a platform.

This method extracts the library and verifies both the checksum and signature.

§Arguments
  • platform - Target platform
  • output_dir - Directory to extract to
  • verify_signature - Whether to verify the signature
  • public_key_override - Optional public key override

Trait Implementations§

Source§

impl Debug for BundleLoader

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.