imath_traits/
lib.rs

1//! imath-traits provides a set of traits which constrain the types used in Rust translations of
2//! C++ APIs that rely on `Imath`, or `Imath-alike` types.
3//!
4//! This is solely about memory layout and being able to convert the implementing types back and
5//! forward into slices and pointers to be able to be used in the FFI call, thus the traits contain
6//! no methods other than for converting back and forth between slices and raw pointers.
7//!
8//! To use, simply add the feature for the math crate you need to the dependency
9//! of any crate that uses imath-traits (these will be called `imath_<crate>`, and types will just work with any function
10//! from that crate that expects a Vec2<T>, Vec3<T>, Vec4<T>, Bound2<T> or Bound3<T>:
11//!
12//! ```toml
13//! openexr = { version = "0.10-3.0.1", features=["imath_cgmath"] }
14//! ```
15//!
16//! Currently, we support glam, nalgebra and nalgebra_glm. If you need another math
17//! crate, implement support for it and submit a PR, or request it. Note that the
18//! crate must support 2-, 3- and 4-dimensional vectors of i32, f32 and f64.
19//!
20
21pub use half::f16;
22
23pub mod vec;
24pub use vec::*;
25
26pub mod bound;
27pub use bound::*;
28
29pub mod matrix;
30pub use matrix::*;
31
32pub mod zero;
33pub use zero::Zero;
34
35#[cfg(feature = "cgmath")]
36pub mod impl_cgmath;
37#[cfg(feature = "cgmath")]
38pub use impl_cgmath::{Box2, Box2d, Box2f, Box2i, Box3, Box3d, Box3f, Box3i};
39
40#[cfg(feature = "glam")]
41pub mod impl_glam;
42#[cfg(feature = "glam")]
43pub use impl_glam::{Box2d, Box2f, Box2i, Box3d, Box3f, Box3i};
44
45#[cfg(feature = "nalgebra")]
46pub mod impl_nalgebra;
47#[cfg(feature = "nalgebra")]
48pub use impl_nalgebra::{Box2d, Box2f, Box2i, Box3d, Box3f, Box3i};
49
50#[cfg(feature = "nalgebra-glm")]
51pub mod impl_nalgebra_glm;
52#[cfg(feature = "nalgebra_glm")]
53pub use impl_nalgebra_glm::{Box2d, Box2f, Box2i, Box3d, Box3f, Box3i};
54
55#[cfg(not(any(
56    feature = "cgmath",
57    feature = "glam",
58    feature = "nalgebra",
59    feature = "nalgebra-glm"
60)))]
61pub mod impl_array;
62#[cfg(not(any(
63    feature = "cgmath",
64    feature = "glam",
65    feature = "nalgebra",
66    feature = "nalgebra-glm"
67)))]
68pub use impl_array::{Box2d, Box2f, Box2i, Box3d, Box3f, Box3i};
69
70#[cfg(test)]
71mod tests {
72    #[test]
73    fn it_works() {
74        assert_eq!(2 + 2, 4);
75    }
76}