Skip to main content

PackBuilder

Struct PackBuilder 

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

Source

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.

Source

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

Source

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

Source

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.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> AppLifecycle for T
where T: ?Sized,

§

fn on_start(&mut self, ctx: &mut dyn AppContext)

Called once after the backend is up but before the first update. Apps install their theme / fonts here.
§

fn on_exit(&mut self)

Called once when the window is closing. Persist state here.
§

impl<T> AsAny for T
where T: Any,

§

fn as_any(&self) -> &(dyn Any + 'static)

Returns a reference to the inner value as &dyn Any.
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
§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

§

fn into_sample(self) -> T

§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,