fuchsia_pkg

Struct PackageBuilder

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

A builder for Fuchsia Packages

Implementations§

Source§

impl PackageBuilder

Source

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

Create a new PackageBuilder.

The ABI revision is included in the package exactly as given - we don’t validate it here.

Source

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

Create a new PackageBuilder with the platform-internal ABI revision.

The platform-internal ABI revision is only appropriate for packages that are only ever read by binaries from the exact same release. For packages that can be built by tools from one release and then run on an OS from a different release, a different ABI revision that defines the compatibility guarantees must be selected.

Source

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

Create a PackageBuilder from a PackageBuildManifest.

The ABI revision is included in the package exactly as given - we don’t validate it here. Returns an error if the given manifest already specified an ABI revision.

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 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 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, D> Encode<Ambiguous1, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _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, D> Encode<Ambiguous2, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _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.

§

impl<T> Instrument for T

§

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

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

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

§

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

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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