Skip to main content

hpr_io/orc/
bundled.rs

1//! The parts catalog OpenRocket 24.12 ships, compiled in.
2
3use std::sync::OnceLock;
4
5use super::{Catalog, read};
6
7/// The `openrocket-database` project's catalog files (Apache-2.0; the license is
8/// `data/openrocket-database/LICENSE` beside them), unchanged, at the commit
9/// `validation/refs.lock.toml` pins (`1512874a`, 2025-07-27), which OpenRocket 24.12 ships byte
10/// for byte: each name with its text, in byte order of the names. `generic_materials.orc` defines
11/// materials and no parts.
12pub const BUNDLED_FILES: &[(&str, &str)] = &[
13    (
14        "BMS.ORC",
15        include_str!("../../data/openrocket-database/BMS.ORC"),
16    ),
17    (
18        "ROCKETARIUM.ORC",
19        include_str!("../../data/openrocket-database/ROCKETARIUM.ORC"),
20    ),
21    (
22        "apogee.orc",
23        include_str!("../../data/openrocket-database/apogee.orc"),
24    ),
25    (
26        "bluetube.orc",
27        include_str!("../../data/openrocket-database/bluetube.orc"),
28    ),
29    (
30        "competition_chutes.orc",
31        include_str!("../../data/openrocket-database/competition_chutes.orc"),
32    ),
33    (
34        "estes_classic.orc",
35        include_str!("../../data/openrocket-database/estes_classic.orc"),
36    ),
37    (
38        "estes_ps2.orc",
39        include_str!("../../data/openrocket-database/estes_ps2.orc"),
40    ),
41    (
42        "generic_materials.orc",
43        include_str!("../../data/openrocket-database/generic_materials.orc"),
44    ),
45    (
46        "giantleaprocketry.orc",
47        include_str!("../../data/openrocket-database/giantleaprocketry.orc"),
48    ),
49    (
50        "loc_precision.orc",
51        include_str!("../../data/openrocket-database/loc_precision.orc"),
52    ),
53    (
54        "madcow.orc",
55        include_str!("../../data/openrocket-database/madcow.orc"),
56    ),
57    (
58        "mpc.orc",
59        include_str!("../../data/openrocket-database/mpc.orc"),
60    ),
61    (
62        "publicmissiles.orc",
63        include_str!("../../data/openrocket-database/publicmissiles.orc"),
64    ),
65    (
66        "quest.orc",
67        include_str!("../../data/openrocket-database/quest.orc"),
68    ),
69    (
70        "semroc.orc",
71        include_str!("../../data/openrocket-database/semroc.orc"),
72    ),
73    (
74        "top_flight.orc",
75        include_str!("../../data/openrocket-database/top_flight.orc"),
76    ),
77];
78
79/// Every part of [`BUNDLED_FILES`], file by file in their order: 3,449 parts. Read once, on the
80/// first call. The files' 55 warnings are dropped here; [`read`] each of [`BUNDLED_FILES`] to see
81/// them.
82#[must_use]
83pub fn bundled() -> &'static Catalog {
84    static CATALOG: OnceLock<Catalog> = OnceLock::new();
85    CATALOG.get_or_init(|| {
86        let mut catalog = Catalog::default();
87        for (name, text) in BUNDLED_FILES {
88            // Invariant: the bundled files are fixed when this crate is built, and the test
89            // `every_bundled_file_reads_with_only_the_known_warnings` reads each of them. A file
90            // that didn't read would add no parts rather than stop the program.
91            let file = read(text, name);
92            debug_assert!(file.is_ok(), "{name} reads");
93            if let Ok(file) = file {
94                catalog.extend(file.catalog);
95            }
96        }
97        catalog
98    })
99}