pub struct PackageBuilder { /* private fields */ }
Expand description

A builder for Fuchsia Packages

Implementations§

source§

impl PackageBuilder

source

pub fn new(name: impl AsRef<str>) -> Self

Create a new PackageBuilder.

source

pub fn from_package_build_manifest( manifest: &PackageBuildManifest ) -> Result<Self>

Create a PackageBuilder from a PackageBuildManifest.

source

pub fn from_manifest( original_manifest: PackageManifest, outdir: impl AsRef<Path> ) -> Result<Self>

Create a PackageBuilder from an existing manifest. Requires an out directory for temporarily unpacking meta.far contents.

source

pub fn manifest_path(&mut self, manifest_path: impl Into<Utf8PathBuf>)

Specify a path to write out the json package manifest to.

source

pub fn manifest_blobs_relative_to(&mut self, relative_to: RelativeTo)

source

pub fn overwrite_files(&mut self, overwrite_files: bool)

Specify whether new additions of a file that have already been added should overwrite, or fail

source

pub fn add_file_to_far( &mut self, at_path: impl AsRef<str>, file: impl AsRef<str> ) -> Result<()>

Add a file to the package’s far.

Errors

Will return an error if the path for the file is already being used. Will return an error if any special package metadata paths are used.

source

pub fn remove_file_from_far(&mut self, at_path: impl AsRef<str>) -> Result<()>

Remove a file from the package’s meta.far.

Errors

Will return an error if the file is not already in the meta.far

source

pub fn add_file_as_blob( &mut self, at_path: impl AsRef<str>, file: impl AsRef<str> ) -> Result<()>

Add a file to the package as a blob itself.

Errors

Will return an error if the path for the file is already being used. Will return an error if any special package metadata paths are used.

source

pub fn remove_blob_file(&mut self, at_path: impl AsRef<str>) -> Result<()>

Remove a file currently in the package as a blob

Errors

Will return an error if the file is not already in the package contents

source

pub fn add_contents_as_blob<C: AsRef<[u8]>>( &mut self, at_path: impl AsRef<str>, contents: C, gendir: impl AsRef<Path> ) -> Result<()>

Write the contents to a file, and add that file as a blob at the given path within the package.

source

pub fn add_contents_to_far<C: AsRef<[u8]>>( &mut self, at_path: impl AsRef<str>, contents: C, gendir: impl AsRef<Path> ) -> Result<()>

Write the contents to a file, and add that file to the metafar at the given path within the package.

source

pub fn add_subpackage( &mut self, url: &RelativePackageUrl, package_hash: Hash, package_manifest_path: PathBuf ) -> Result<()>

Helper fn to include a subpackage into this package.

source

pub fn api_level(&mut self, api_level: u64) -> Result<()>

Set the API Level that should be included in the package. This will return an error if there is no ABI revision that corresponds with this API Level.

source

pub fn abi_revision(&mut self, abi_revision: u64)

Set the ABI Revision that should be included in the package.

source

pub fn name(&mut self, name: impl AsRef<str>)

Set the name of the package.

source

pub fn published_name(&mut self, published_name: impl AsRef<str>)

Set a different name for the package to be published by (and to be included in the generated PackageManifest), than the one embedded in the package itself.

source

pub fn repository(&mut self, repository: impl AsRef<str>)

Set a repository for the package to be included in the generated PackageManifest.

source

pub fn read_contents_from_far(&self, file_path: &str) -> Result<Vec<u8>>

Read the contents of a file already added to the builder’s meta.far.

source

pub fn build( self, gendir: impl AsRef<Path>, metafar_path: impl AsRef<Path> ) -> Result<PackageManifest>

Build the package, using the specified dir, returning the PackageManifest.

If a path for the manifest was specified, the PackageManifest will also be written to there.

The gendir param is assumed to be a path to folder which is only used by this package’s creation, so this fn does not try to create paths within it that are unique across different packages.

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> Encode<Ambiguous1> for T

source§

unsafe fn encode( self, _encoder: &mut Encoder<'_>, _offset: usize, _depth: Depth ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
source§

impl<T> Encode<Ambiguous2> for T

source§

unsafe fn encode( self, _encoder: &mut Encoder<'_>, _offset: usize, _depth: Depth ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.
§

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

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more