Skip to main content

Bake

Struct Bake 

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

What a game bakes into a pack: which assets of which kinds, the same way its loaders ask for them (asset as Formats::load, under as Formats::load_under), and its stamp. Every other file of the bundle goes into the pack as its own bytes.

A file whose bytes something other than its kind’s format reads (a picture the platform draws, a sound it plays, a file another format reads beside its own) stays as it is, or is baked in a format that reader knows (under_as): bake only kinds whose files nothing else reads.

Implementations§

Source§

impl Bake

Source

pub fn new(stamp: impl Into<String>) -> Self

A bake of nothing yet, with stamp: the game’s word for the shapes of its own kinds (its version, say), which Pack::open then asks for.

Source

pub fn stamp(&self) -> &str

The stamp.

Source

pub fn asset<K: Bakeable>(self, id: &str) -> Self

This bake, baking the asset of kind K with id id (data/palette or data/palette.ron).

Source

pub fn under<K: Bakeable>(self, dir: &str) -> Self

This bake, baking every file of kind K under directory dir ("" for the whole bundle) whose extension a format of the kind claims.

Source

pub fn under_as<F>(self, dir: &str, format: F) -> Self
where F: Encode + Clone, F::Asset: PartialEq,

This bake, baking every file of format’s kind under directory dir ("" for the whole bundle) whose extension a format of the kind claims, read with the bake’s formats, and kept in the pack in format’s own bytes (Encode) instead of the pack’s binary form: an optimized format derived from its source (ADR-0007 §4), which whatever reads the file on the target reads as it is. A one-bit target’s pictures go in as one-bit picture files so, each at its PNG’s path:

use shuyi_assets::bitmap::OneBitFile;
use shuyi_assets::pack::Bake;

let bake = Bake::new("my-game 1").under_as("", OneBitFile);
assert_eq!(bake.kinds(), ["one-bit picture"]);

register registers format where its kind lacks it, and check proves each such file of the pack, read by it, equal to its source read with the bake’s formats. A file baked so is baked as no other kind.

Source

pub fn kinds(&self) -> Vec<&'static str>

The names of the kinds it bakes, each once, in the order first named.

Source

pub fn register(&self, formats: &mut Formats) -> Result<(), RegisterError>

Registers in formats the format of a baked file of every kind it bakes (Packed), where it isn’t already: what a game that loads a pack does at start-up.

Source

pub fn bake( &self, formats: &Formats, bundle: &Bundle, target: Option<&str>, ) -> Result<Baked, Vec<ContentError>>

The pack of bundle, baked for target: each file this bake names holds its assets read with formats (or, baked under_as a format, that format’s bytes), every other file its own bytes, and its index holds bundle’s fingerprint, which the pack then stands for. Import settings files go in as their own bytes too, once they check (Formats::check_import_settings). Refuses a source with errors: every one of them is returned.

Source

pub fn load(&self, formats: &Formats, bundle: &Bundle) -> Vec<ContentError>

Reads every asset this bake names from bundle with formats, as the game’s loaders would, and drops them: what shuyi bake times, from the sources and from the pack. Every error found.

Source

pub fn check( &self, formats: &Formats, source: &Bundle, pack: &Bundle, ) -> Vec<ContentError>

Every way pack (a bundle of a baked pack) differs from source, the bundle it was baked from: an asset this bake names that reads differently from the two with formats (which must have the pack’s formats: register), a file the pack lacks or adds, or one kept as its own bytes that changed. None if the pack is true to its sources.

Trait Implementations§

Source§

impl Debug for Bake

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Bake

§

impl !UnwindSafe for Bake

§

impl Freeze for Bake

§

impl Send for Bake

§

impl Sync for Bake

§

impl Unpin for Bake

§

impl UnsafeUnpin for Bake

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