#serialization #serde #data #encoding #binary

bakery

Deserialize binary objects from structured text data files

4 releases

0.1.3 Nov 27, 2021
0.1.2 Nov 21, 2021
0.1.1 Nov 20, 2021
0.1.0 Oct 24, 2021

#438 in Encoding

MIT/Apache

88KB
2K SLoC

Bakery

A Rust library to deserialize binary objects from structured text data 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");

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

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();

Dependencies

~3MB
~68K SLoC

ka