write_brick/
write_brick.rs1use brdb::{BrFsReader, Brdb, Brick, IntoReader, World};
2use std::path::PathBuf;
3
4fn main() -> Result<(), Box<dyn std::error::Error>> {
6 let path = PathBuf::from("./example_brick.brdb");
7
8 let mut world = World::new();
9 world.meta.bundle.description = "Example World".to_string();
10 world.bricks.push(Brick {
11 position: (0, 0, 6).into(),
12 color: (255, 0, 0).into(),
13 ..Default::default()
14 });
15
16 world.write_brdb(&path)?;
17
18 let db = Brdb::new(&path)?.into_reader();
19
20 println!("file structure: {}", db.get_fs()?.render());
21
22 let soa = db.brick_chunk_soa(1, (0, 0, 0).into())?;
23 let color = soa.colors_and_alphas[0];
24 assert_eq!(color.r, 255);
25 assert_eq!(color.g, 0);
26 assert_eq!(color.b, 0);
27 assert_eq!(color.a, 5);
28
29 Ok(())
30}