Skip to main content

bread_format/
lib.rs

1/*
2 * SPDX-FileCopyrightText: 2026 SynrgStudio
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
6//! Reads and writes `.bread` files: triangle meshes and the scene that places
7//! them, stored small and without losing anything. The format is described in
8//! [`SPEC.md`](https://github.com/breadslicer-app/bread-format/blob/main/SPEC.md),
9//! in the repository.
10//!
11//! [`read_file`] and [`write_file`] read and write a whole file as a
12//! [`BreadFile`]: the scene, its meshes, and the documents programs keep
13//! about them, such as editable supports.
14//!
15//! A `.bread` file is a short header followed by chunks. Each chunk has a
16//! four-byte tag, its own version, and a payload compressed with zstd and
17//! guarded by a CRC-32. [`container`] reads and writes chunks without knowing
18//! what they hold; [`scene`] and [`mesh`] are the codecs of the scene chunk
19//! and of the mesh chunks it places, [`app`] carries the documents of the
20//! application chunks, [`preview`] the meshes that show supports to readers
21//! that do not rebuild them, and [`surface`] the paint on the faces of models.
22//! [`stl`] reads STL files into meshes, to be written as `.bread`.
23
24pub mod app;
25mod bytes;
26pub mod container;
27pub mod file;
28pub mod mesh;
29pub mod mesh_v2;
30mod meta;
31mod parallel;
32pub mod preview;
33pub mod scene;
34pub mod stl;
35pub mod surface;
36
37#[cfg(test)]
38mod tests_app;
39#[cfg(test)]
40mod tests_container;
41#[cfg(test)]
42mod tests_file;
43#[cfg(test)]
44mod tests_mesh;
45#[cfg(test)]
46mod tests_mesh_v2;
47#[cfg(test)]
48mod tests_preview;
49#[cfg(test)]
50mod tests_scene;
51#[cfg(test)]
52mod tests_stl;
53#[cfg(test)]
54mod tests_surface;
55
56pub use app::{
57    DecodeDocumentsError, EncodeDocumentsError, HOLLOWS_TAG, HOLLOWS_VERSION, HollowEntry,
58    SETTINGS_TAG, SETTINGS_VERSION, SUPPORTS_TAG, SUPPORTS_VERSION, SupportEntry, decode_hollows,
59    decode_supports, encode_hollows, encode_supports,
60};
61pub use container::{BreadReader, BreadWriter, Chunk, ChunkTag, ReadBreadError};
62pub use file::{
63    BreadFile, ReadFileError, THUMBNAIL_TAG, THUMBNAIL_VERSION, WriteFileError, read_file,
64    supported_version, write_file,
65};
66pub use mesh::{
67    DecodeMeshError, EncodeMeshError, MESH_TAG, MESH_VERSION, Mesh, decode_mesh, encode_mesh,
68};
69pub use mesh_v2::{
70    Connectivity, MeshCoding, VertexCoding, decode_mesh_v2, encode_mesh_v2, encode_mesh_v2_with,
71};
72pub use meta::Meta;
73pub use preview::{
74    DecodePreviewsError, EncodePreviewsError, SUPPORT_PREVIEW_TAG, SUPPORT_PREVIEW_VERSION,
75    SupportPreview, decode_previews, encode_previews,
76};
77pub use scene::{
78    DecodeSceneError, EncodeSceneError, Node, NodeKind, SCENE_TAG, SCENE_VERSION, Scene, Transform,
79    decode_scene, encode_scene,
80};
81pub use stl::{ReadStlError, read_stl};
82pub use surface::{
83    DecodeSurfaceError, EncodeSurfaceError, SURFACE_TAG, SURFACE_VERSION, SurfaceEntry,
84    decode_surface, encode_surface,
85};