pub struct ProviderArchive { /* private fields */ }
Expand description
A provider archive is a specialized ZIP file that contains a set of embedded and signed claims (a .JWT file) as well as a list of binary files, one plugin library for each supported target architecture and OS combination
Implementations§
Source§impl ProviderArchive
impl ProviderArchive
Sourcepub fn new(
name: &str,
vendor: &str,
rev: Option<i32>,
ver: Option<String>,
) -> ProviderArchive
pub fn new( name: &str, vendor: &str, rev: Option<i32>, ver: Option<String>, ) -> ProviderArchive
Creates a new provider archive in memory, to which native library files can be added.
Sourcepub fn add_library(&mut self, target: &str, input: &[u8]) -> Result<()>
pub fn add_library(&mut self, target: &str, input: &[u8]) -> Result<()>
Adds a native library file (.so, .dylib, .dll) to the archive for a given target string
Sourcepub fn add_wit_world(&mut self, world: &[u8]) -> Result<()>
pub fn add_wit_world(&mut self, world: &[u8]) -> Result<()>
Adds a WIT file encoded as a wasm module to the archive
Sourcepub fn set_schema(&mut self, schema: Value) -> Result<()>
pub fn set_schema(&mut self, schema: Value) -> Result<()>
Sets a JSON schema for this provider’s link definition specification. This will be injected into the claims written to a provider’s PAR file, so you’ll need to do this after instantiation and prior to writing
Sourcepub fn targets(&self) -> Vec<String>
pub fn targets(&self) -> Vec<String>
Gets the list of architecture/OS targets within the archive
Sourcepub fn target_bytes(&self, target: &str) -> Option<Vec<u8>>
pub fn target_bytes(&self, target: &str) -> Option<Vec<u8>>
Retrieves the raw bytes for a given target
Sourcepub fn claims(&self) -> Option<Claims<CapabilityProvider>>
pub fn claims(&self) -> Option<Claims<CapabilityProvider>>
Returns the embedded claims associated with this archive. Note that claims are not available while building a new archive. They are only available after the archive has been written or if the archive was loaded from an existing file
Sourcepub fn claims_token(&self) -> Option<Token<CapabilityProvider>>
pub fn claims_token(&self) -> Option<Token<CapabilityProvider>>
Returns the embedded claims token associated with this archive.
Sourcepub fn schema(&self) -> Option<Value>
pub fn schema(&self) -> Option<Value>
Obtains the JSON schema if one was either set explicitly on the structure or loaded from claims in the PAR
Sourcepub async fn try_load(input: &[u8]) -> Result<ProviderArchive>
pub async fn try_load(input: &[u8]) -> Result<ProviderArchive>
Attempts to read a Provider Archive (PAR) file’s bytes to analyze and verify its contents.
The embedded claims in this archive will be validated, and the file hashes contained in
those claims will be compared and verified against hashes computed at load time. This
prevents the contents of the archive from being modified without the embedded claims being
re-signed. This will load all binaries into memory in the returned ProviderArchive
.
Please note that this method requires that you have all of the provider archive bytes in memory, which will likely be really hefty if you are just trying to load a specific binary to run
Sourcepub async fn try_load_target(
input: &[u8],
target: &str,
) -> Result<ProviderArchive>
pub async fn try_load_target( input: &[u8], target: &str, ) -> Result<ProviderArchive>
Attempts to read a Provider Archive (PAR) file’s bytes to analyze and verify its contents, loading only the specified target.
This is useful when loading a provider archive for consumption and you know the target OS you need. The embedded claims in this archive will be validated, and the file hashes contained in those claims will be compared and verified against hashes computed at load time. This prevents the contents of the archive from being modified without the embedded claims being re-signed
Please note that this method requires that you have all of the provider archive bytes in memory, which will likely be really hefty if you are just trying to load a specific binary to run
Sourcepub async fn try_load_file(path: impl AsRef<Path>) -> Result<ProviderArchive>
pub async fn try_load_file(path: impl AsRef<Path>) -> Result<ProviderArchive>
Attempts to read a Provider Archive (PAR) file to analyze and verify its contents.
The embedded claims in this archive will be validated, and the file hashes contained in
those claims will be compared and verified against hashes computed at load time. This
prevents the contents of the archive from being modified without the embedded claims being
re-signed. This will load all binaries into memory in the returned ProviderArchive
. Use
[load
] or [try_load_target_from_file
] methods if you only want to load a single binary
into memory.
Sourcepub async fn try_load_target_from_file(
path: impl AsRef<Path>,
target: &str,
) -> Result<ProviderArchive>
pub async fn try_load_target_from_file( path: impl AsRef<Path>, target: &str, ) -> Result<ProviderArchive>
Attempts to read a Provider Archive (PAR) file to analyze and verify its contents.
The embedded claims in this archive will be validated, and the file hashes contained in those claims will be compared and verified against hashes computed at load time. This prevents the contents of the archive from being modified without the embedded claims being re-signed. This will only read a single binary into memory.
It is recommended to use this method or the [load
] method when consuming a provider
archive. Otherwise all binaries will be loaded into memory
Sourcepub async fn load<R: AsyncRead + AsyncSeek + Unpin + Send + Sync>(
input: &mut R,
target: Option<&str>,
) -> Result<ProviderArchive>
pub async fn load<R: AsyncRead + AsyncSeek + Unpin + Send + Sync>( input: &mut R, target: Option<&str>, ) -> Result<ProviderArchive>
Attempts to read a Provider Archive (PAR) from a Reader to analyze and verify its contents.
The optional target
parameter allows you to select a single binary to load
The embedded claims in this archive will be validated, and the file hashes contained in
those claims will be compared and verified against hashes computed at load time. This
prevents the contents of the archive from being modified without the embedded claims being
re-signed. If a target
is specified, this will only read a single binary into memory.
This is the most generic loading option available and allows you to load from anything that
implements AsyncRead
and AsyncSeek