Struct PackageBuilder

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

A builder for creating a ResourcePackage.


    let mut builder = PackageBuilder::new_with_patch_id(PartitionId::default(), PatchId::Base);
    builder.with_resource(PackageResourceBuilder::from_memory(RuntimeResourceID::default(), "TYPE", vec![0,1,2,3,4,5], None, false).unwrap());
    builder.build(PackageVersion::RPKGv2, output_path)?;

    assert!(temp_dir.path().join("chunk0.rpkg").exists());

Implementations§

Source§

impl PackageBuilder

Source

pub fn new(chunk_id: u8, chunk_type: ChunkType) -> Self

Creates a new package builder.

§Arguments
  • chunk_id - The chunk ID of the package. e.g. chunk0
  • chunk_type - The chunk type of the package.
Source

pub fn new_with_patch_id(partition_id: PartitionId, patch_id: PatchId) -> Self

Creates a new package builder using the given partition id and patch id.

§Arguments
  • partition_id - The partition id of the package.
  • patch_id - The patch id of the package.
Source

pub fn from_resource_package( resource_package: &ResourcePackage, ) -> Result<Self, PackageBuilderError>

Creates a new package builder by duplicating an existing ResourcePackage.

§Arguments
  • resource_package - The ResourcePackage to duplicate.
Source

pub fn with_partition_id(&mut self, partition_id: &PartitionId) -> &mut Self

Sets the partition ID of the package.

Source

pub fn with_patch_id(&mut self, patch_id: &PatchId) -> &mut Self

Sets the patch ID of the package.

Source

pub fn use_legacy_references(&mut self) -> &mut Self

When this flag is set it will build the reference flags with the legacy format

Source

pub fn with_resource(&mut self, resource: PackageResourceBuilder) -> &mut Self

Adds a resource to the package.

If a resource with the same resource ID already exists, it will be overwritten.

§Arguments
  • resource - The resource to add to the package.
Source

pub fn with_unneeded_resource(&mut self, rrid: RuntimeResourceID) -> &mut Self

Adds an unneeded resource to the package.

§Arguments
  • rrid - The resource ID of the resource.
Source

pub fn build( self, version: PackageVersion, output_path: &Path, ) -> Result<(), PackageBuilderError>

👎Deprecated since 1.1.1: use build_to_file instead
Source

pub fn build_to_writer<W: Write + Seek>( self, version: PackageVersion, writer: &mut W, ) -> Result<(), PackageBuilderError>

Builds the package for the given version and writes it to the given writer.

§Arguments
  • version - The version of the package to build.
  • writer - The struct implementing the Write and Seek traits.
Source

pub fn build_to_file<P: AsRef<Path>>( self, version: PackageVersion, output_path: P, ) -> Result<(), PackageBuilderError>

Builds the package for the given version and writes it to the given path.

§Arguments
  • version - The version of the package to build.
  • output_path - The path to the output file.
Source

pub fn build_in_memory( self, version: PackageVersion, ) -> Result<Vec<u8>, PackageBuilderError>

👎Deprecated since 1.1.1: use build_to_vec instead
Source

pub fn build_to_vec( self, version: PackageVersion, ) -> Result<Vec<u8>, PackageBuilderError>

Builds the package for the given version and returns it as a byte vector.

§Arguments
  • version - The version of the package to build.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.