1#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
3pub enum Precision {
4 Single,
6 Double,
8}
9
10impl Precision {
11 pub const ACTIVE: Self = if cfg!(feature = "double-precision") {
13 Self::Double
14 } else {
15 Self::Single
16 };
17
18 pub const fn as_str(self) -> &'static str {
20 match self {
21 Self::Single => "single",
22 Self::Double => "double",
23 }
24 }
25
26 pub const fn is_double(self) -> bool {
28 matches!(self, Self::Double)
29 }
30
31 pub const fn pregenerated_bindings_file(self) -> &'static str {
33 match self {
34 Self::Single => "bindings_pregenerated.rs",
35 Self::Double => "bindings_double.rs",
36 }
37 }
38
39 pub const fn wasm_import_module(self) -> &'static str {
41 match self {
42 Self::Single => "box2d-sys-v2-single",
43 Self::Double => "box2d-sys-v2-double",
44 }
45 }
46}
47
48#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
50pub struct SinglePrecision;
51
52#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
54pub struct DoublePrecision;
55
56#[cfg(not(feature = "double-precision"))]
58pub type ActivePrecision = SinglePrecision;
59
60#[cfg(feature = "double-precision")]
62pub type ActivePrecision = DoublePrecision;
63
64pub const ABI_PRECISION: Precision = Precision::ACTIVE;
66
67pub const IS_DOUBLE_PRECISION: bool = ABI_PRECISION.is_double();