Skip to main content

bake_packaged_format

Function bake_packaged_format 

Source
pub fn bake_packaged_format(packaged: &[u8]) -> Option<Vec<u8>>
Expand description

Converts a compressed packaged format into a flat static bake.

Examples found in repository?
examples/bake_static_format.rs (line 18)
6fn main() -> ExitCode {
7    let Some((input, output)) = paths() else {
8        eprintln!("usage: bake_static_format <packaged input> <baked output>");
9        return ExitCode::FAILURE;
10    };
11    let packaged = match std::fs::read(&input) {
12        Ok(bytes) => bytes,
13        Err(error) => {
14            eprintln!("cannot read {}: {error}", input.display());
15            return ExitCode::FAILURE;
16        }
17    };
18    let Some(baked) = mathtex_engine::generated::bake_packaged_format(&packaged) else {
19        eprintln!("input is not a packaged format for this build target");
20        return ExitCode::FAILURE;
21    };
22    if let Err(error) = std::fs::write(&output, baked) {
23        eprintln!("cannot write {}: {error}", output.display());
24        return ExitCode::FAILURE;
25    }
26    ExitCode::SUCCESS
27}