Struct provider_archive::ProviderArchive

source ·
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

source

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.

source

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

source

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

source

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

Gets the list of architecture/OS targets within the archive

source

pub fn target_bytes(&self, target: &str) -> Option<Vec<u8>>

Retrieves the raw bytes for a given target

source

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

source

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

source

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

source

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

source

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.

source

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

source

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

source

pub async fn write( &mut self, destination: impl AsRef<Path>, issuer: &KeyPair, subject: &KeyPair, compress_par: bool ) -> Result<()>

Generates a Provider Archive (PAR) file with all of the library files and a signed set of claims in an embedded JWT

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

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V