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) -> PackBuilder<'a>
pub fn new(assets_root: &'a Path, dest_dir: &'a Path) -> PackBuilder<'a>
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>) -> PackBuilder<'a>
pub fn with_progress(self, tx: Sender<PackProgress>) -> PackBuilder<'a>
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) -> PackBuilder<'a>
pub fn with_compression(self, compression: CompressionKind) -> PackBuilder<'a>
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) -> PackBuilder<'a>
pub fn with_manifest(self, enable: bool) -> PackBuilder<'a>
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, Error>
pub fn build(self) -> Result<PackOutput, Error>
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§
§impl<T> AppLifecycle for Twhere
T: ?Sized,
impl<T> AppLifecycle for Twhere
T: ?Sized,
§fn on_start(&mut self, ctx: &mut dyn AppContext)
fn on_start(&mut self, ctx: &mut dyn AppContext)
update. Apps install their theme / fonts here.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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<F, T, S> SimdInto<T, S> for Fwhere
T: SimdFrom<F, S>,
S: Simd,
impl<F, T, S> SimdInto<T, S> for Fwhere
T: SimdFrom<F, S>,
S: Simd,
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.