pub struct PackBuilder<'a> { /* private fields */ }Expand description
Builds a release pack from a project’s assets/ directory.
use khora_io::asset::{PackBuilder, PackProgress};
let (tx, rx) = crossbeam_channel::unbounded::<PackProgress>();
std::thread::spawn(move || {
while let Ok(ev) = rx.recv() { /* update UI */ }
});
let out = PackBuilder::new(&project_assets_dir, &dest_dir)
.with_progress(tx)
.build()?;Implementations§
Source§impl<'a> PackBuilder<'a>
impl<'a> PackBuilder<'a>
Sourcepub fn new(assets_root: &'a Path, dest_dir: &'a Path) -> Self
pub fn new(assets_root: &'a Path, dest_dir: &'a Path) -> Self
Creates a new builder. assets_root is the project’s assets/
directory (the same path that ProjectVfs watches in dev mode).
dest_dir is where index.bin + data.pack will be written —
created if missing.
Sourcepub fn with_progress(self, tx: Sender<PackProgress>) -> Self
pub fn with_progress(self, tx: Sender<PackProgress>) -> Self
Forwards incremental progress to tx. Drop the receiver to silently
disable progress (the sends are best-effort and never block).
Sourcepub fn with_compression(self, compression: CompressionKind) -> Self
pub fn with_compression(self, compression: CompressionKind) -> Self
Sets the per-entry compression scheme. Default is
[CompressionKind::None]. When set to LZ4, every asset is
compressed individually so the runtime can decompress on demand
(no global state, no streaming gzip).
Sourcepub fn with_manifest(self, enable: bool) -> Self
pub fn with_manifest(self, enable: bool) -> Self
Emits a manifest.bin sidecar with BLAKE3 hashes of every
uncompressed asset. The runtime opts in via
RuntimeConfig::verify_integrity to detect corruption /
tampering at load time.
Sourcepub fn build(self) -> Result<PackOutput>
pub fn build(self) -> Result<PackOutput>
Performs the build. Side effects:
- creates
<dest_dir>/if missing, - writes
<dest_dir>/data.pack(concatenation of asset bytes), - writes
<dest_dir>/index.bin(bincode-encoded metadata).
The two files together are everything khora_runtime needs to load
the project at runtime via crate::asset::PackLoader.
Auto Trait Implementations§
impl<'a> Freeze for PackBuilder<'a>
impl<'a> RefUnwindSafe for PackBuilder<'a>
impl<'a> Send for PackBuilder<'a>
impl<'a> Sync for PackBuilder<'a>
impl<'a> Unpin for PackBuilder<'a>
impl<'a> UnsafeUnpin for PackBuilder<'a>
impl<'a> UnwindSafe for PackBuilder<'a>
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
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>
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>
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