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
impl BundleLoader
Sourcepub fn open<P: AsRef<Path>>(path: P) -> BundleResult<Self>
pub fn open<P: AsRef<Path>>(path: P) -> BundleResult<Self>
Open a bundle file for reading.
Sourcepub fn supports_current_platform(&self) -> bool
pub fn supports_current_platform(&self) -> bool
Check if the bundle supports the current platform.
Sourcepub fn current_platform_info(&self) -> Option<&PlatformInfo>
pub fn current_platform_info(&self) -> Option<&PlatformInfo>
Get the platform info for the current platform.
Sourcepub fn extract_library<P: AsRef<Path>>(
&mut self,
platform: Platform,
output_dir: P,
) -> BundleResult<PathBuf>
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.
Sourcepub fn extract_library_variant<P: AsRef<Path>>(
&mut self,
platform: Platform,
variant: &str,
output_dir: P,
) -> BundleResult<PathBuf>
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.
Sourcepub fn list_variants(&self, platform: Platform) -> Vec<&str>
pub fn list_variants(&self, platform: Platform) -> Vec<&str>
List all available variants for a platform.
Sourcepub fn has_variant(&self, platform: Platform, variant: &str) -> bool
pub fn has_variant(&self, platform: Platform, variant: &str) -> bool
Check if a specific variant exists for a platform.
Sourcepub fn build_info(&self) -> Option<&BuildInfo>
pub fn build_info(&self) -> Option<&BuildInfo>
Get the top-level build info from the manifest.
Sourcepub fn effective_build_info(
&self,
platform: &str,
variant: &str,
) -> Option<&BuildInfo>
pub fn effective_build_info( &self, platform: &str, variant: &str, ) -> Option<&BuildInfo>
Get the effective build info for a platform/variant (variant-level overrides top-level).
Sourcepub fn effective_sbom(&self, platform: &str, variant: &str) -> Option<&Sbom>
pub fn effective_sbom(&self, platform: &str, variant: &str) -> Option<&Sbom>
Get the effective SBOM for a platform/variant (variant-level overrides top-level).
Sourcepub fn extract_library_for_current_platform<P: AsRef<Path>>(
&mut self,
output_dir: P,
) -> BundleResult<PathBuf>
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.
Sourcepub fn read_file(&mut self, path: &str) -> BundleResult<Vec<u8>>
pub fn read_file(&mut self, path: &str) -> BundleResult<Vec<u8>>
Read a file from the bundle as bytes.
Sourcepub fn read_file_string(&mut self, path: &str) -> BundleResult<String>
pub fn read_file_string(&mut self, path: &str) -> BundleResult<String>
Read a file from the bundle as a string.
Sourcepub fn list_files(&self) -> Vec<String>
pub fn list_files(&self) -> Vec<String>
List all files in the bundle.
Sourcepub fn has_signatures(&self) -> bool
pub fn has_signatures(&self) -> bool
Check if the bundle has signature files.
Sourcepub fn public_key(&self) -> Option<&str>
pub fn public_key(&self) -> Option<&str>
Get the public key from the manifest.
Sourcepub fn verify_manifest_signature(&mut self) -> BundleResult<()>
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.
Sourcepub fn verify_manifest_signature_with_key(
&mut self,
public_key_override: Option<&str>,
) -> BundleResult<()>
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
Sourcepub fn verify_library_signature(
&mut self,
library_path: &str,
library_data: &[u8],
) -> BundleResult<()>
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 bundlelibrary_data- The library file contents
Sourcepub fn verify_library_signature_with_key(
&mut self,
library_path: &str,
library_data: &[u8],
public_key_override: Option<&str>,
) -> BundleResult<()>
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.
Sourcepub fn extract_library_verified<P: AsRef<Path>>(
&mut self,
platform: Platform,
output_dir: P,
verify_signature: bool,
public_key_override: Option<&str>,
) -> BundleResult<PathBuf>
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 platformoutput_dir- Directory to extract toverify_signature- Whether to verify the signaturepublic_key_override- Optional public key override