sb3_decoder/
lib.rs

1//! # `sb3-decoder`
2//! A Rust library for decoding Scratch 3.0 project files (.sb3) into Rust structs.
3//!
4//! # Example
5//! ```no_run
6//! use sb3_decoder::prelude::*;
7//!
8//! let mut decoder = DecoderBuilder::new()
9//!     .use_file("path/to/project.sb3") // Open a file
10//! #   .use_bytes(&[]) /*
11//!     .use_bytes(include_bytes!("path/to/project.sb3")) // Or use bytes directly
12//! # */
13//!     .build()
14//!     .unwrap();
15//! let project = decoder.decode().unwrap();
16//! ```
17//!
18//! # Features
19//! - `costume_png`: Enable support for rasterizing SVG costumes to PNG.
20//! - `costume_svg`: Enable support for handling SVG costumes directly.
21//!
22//! **Note:** The features `costume_png` and `costume_svg` are mutually exclusive; enable only one
23//! of them.
24
25#[cfg(all(feature = "costume_png", feature = "costume_svg"))]
26compile_error!(
27    "Features `costume_png` and `costume_svg` are mutually exclusive; enable only one of them."
28);
29
30#[cfg(all(not(feature = "costume_png"), not(feature = "costume_svg")))]
31compile_error!("Either feature `costume_png` or `costume_svg` must be enabled.");
32
33pub mod decoder;
34pub mod error;
35pub mod structs;
36pub(crate) mod utils;
37
38pub mod prelude;
39
40#[cfg(feature = "costume_png")]
41pub use image;
42
43#[cfg(feature = "costume_svg")]
44pub use usvg;
45
46#[cfg(test)]
47mod tests;