Expand description
This crate allows loading text data files as serialized binary objects.
Data files can have a syntax similar to rust data definition, and must follow a recipe (or
schema) defined either in a recipe file or built in the program using the Recipe
trait.
When a data file is parsed, a binary representation is built and cached into a binary file, and
this binary representation can then be easily deserialized using, for instance, serde
and
bincode
crates. If the data file has not been modified, loading it uses the cache and is
therefore very fast. This is very efficient for instance for storing complex asset files in a
comprehensible and easily modifiable format. It may also be useful for loading configuration
files.
§Basic example
use bakery::load_from_string;
use bakery_derive::Recipe;
use serde::Deserialize;
#[derive(Recipe, Deserialize)]
struct GameConfig {
width: u32,
height: u32,
fullscreen: bool
}
let config: GameConfig = load_from_string("width: 1024, height: 768, fullscreen: true").unwrap();
Structs§
- Node
- Node for recipe tree
- Source
Location
Enums§
- Load
Error - Node
Content - Possible elements from recipe and data files
- RecType
Id - Identifies a type in the node tree Set by string during parsing, then revolved as a node id during compilation
- Rule
Traits§
Functions§
- load_
from_ file - Load an object from a data file, with recipe built using
Recipe
trait. - load_
from_ file_ with_ recipe - Load an object from a data file, given a recipe defined in a recipe file.
- load_
from_ string - Load data from a string, with recipe built using
Recipe
trait. - write_
from_ string_ with_ recipe - Write the binary representation of string data to be compiled, with the recipe given as a string.