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
impl PackageBuilder
Sourcepub fn new(chunk_id: u8, chunk_type: ChunkType) -> Self
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. chunk0chunk_type
- The chunk type of the package.
Sourcepub fn new_with_patch_id(partition_id: PartitionId, patch_id: PatchId) -> Self
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.
Sourcepub fn from_resource_package(
resource_package: &ResourcePackage,
) -> Result<Self, PackageBuilderError>
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.
Sourcepub fn with_partition_id(&mut self, partition_id: &PartitionId) -> &mut Self
pub fn with_partition_id(&mut self, partition_id: &PartitionId) -> &mut Self
Sets the partition ID of the package.
Sourcepub fn with_patch_id(&mut self, patch_id: &PatchId) -> &mut Self
pub fn with_patch_id(&mut self, patch_id: &PatchId) -> &mut Self
Sets the patch ID of the package.
Sourcepub fn use_legacy_references(&mut self) -> &mut Self
pub fn use_legacy_references(&mut self) -> &mut Self
When this flag is set it will build the reference flags with the legacy format
Sourcepub fn with_resource(&mut self, resource: PackageResourceBuilder) -> &mut Self
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.
Sourcepub fn with_unneeded_resource(&mut self, rrid: RuntimeResourceID) -> &mut Self
pub fn with_unneeded_resource(&mut self, rrid: RuntimeResourceID) -> &mut Self
pub fn build( self, version: PackageVersion, output_path: &Path, ) -> Result<(), PackageBuilderError>
👎Deprecated since 1.1.1: use
build_to_file
insteadSourcepub fn build_to_writer<W: Write + Seek>(
self,
version: PackageVersion,
writer: &mut W,
) -> Result<(), PackageBuilderError>
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.
Sourcepub fn build_to_file<P: AsRef<Path>>(
self,
version: PackageVersion,
output_path: P,
) -> Result<(), PackageBuilderError>
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.
pub fn build_in_memory( self, version: PackageVersion, ) -> Result<Vec<u8>, PackageBuilderError>
👎Deprecated since 1.1.1: use
build_to_vec
insteadSourcepub fn build_to_vec(
self,
version: PackageVersion,
) -> Result<Vec<u8>, PackageBuilderError>
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§
impl Freeze for PackageBuilder
impl RefUnwindSafe for PackageBuilder
impl Send for PackageBuilder
impl Sync for PackageBuilder
impl Unpin for PackageBuilder
impl UnwindSafe for PackageBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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