sable_core/lib.rs
1//! # Sable Core
2//!
3//! Core utilities, math primitives, and foundational types for the Sable engine.
4//!
5//! ## Modules
6//!
7//! - [`math`] — Vector, matrix, and quaternion types
8//! - [`handle`] — Generational index handles for safe resource references
9//! - [`color`] — Color types with various color space support
10//! - [`time`] — Time tracking and delta time utilities
11//!
12//! ## Feature Flags
13//!
14//! - `f64` — Use 64-bit floats instead of 32-bit for math types
15//! - `parallel` — Enable parallel iteration with rayon and concurrent data structures
16//! - `async` — Enable async time utilities with tokio
17//!
18//! ## Parallelization
19//!
20//! With the `parallel` feature (enabled by default), you can use parallel iteration:
21//!
22//! ```rust,ignore
23//! use rayon::prelude::*;
24//!
25//! // Parallel iteration over handle allocator values
26//! allocator.par_values().for_each(|value| {
27//! // Process in parallel
28//! });
29//!
30//! // Thread-safe concurrent allocator
31//! use sable_core::handle::ConcurrentHandleAllocator;
32//! let allocator = ConcurrentHandleAllocator::new();
33//! ```
34//!
35//! ## Async Support
36//!
37//! With the `async` feature, async time utilities are available:
38//!
39//! ```rust,ignore
40//! use sable_core::time::async_time::{sleep, Interval, timeout};
41//!
42//! async fn game_loop() {
43//! let mut interval = Interval::from_hz(60.0);
44//! loop {
45//! interval.tick().await;
46//! update();
47//! }
48//! }
49//! ```
50
51#![warn(missing_docs)]
52#![warn(clippy::all)]
53#![warn(clippy::pedantic)]
54#![allow(clippy::module_name_repetitions)]
55#![allow(clippy::many_single_char_names)]
56#![allow(clippy::similar_names)]
57// Math code commonly uses intentional truncation and precision loss
58#![allow(clippy::cast_possible_truncation)]
59#![allow(clippy::cast_precision_loss)]
60#![allow(clippy::cast_sign_loss)]
61#![allow(clippy::cast_lossless)]
62#![allow(clippy::struct_field_names)]
63
64pub mod color;
65pub mod handle;
66pub mod math;
67pub mod time;
68
69/// Prelude module for convenient imports.
70pub mod prelude {
71 pub use crate::color::{Color, LinearRgba, Srgba};
72 pub use crate::handle::{Handle, HandleAllocator};
73 pub use crate::math::{Mat3, Mat4, Quat, Vec2, Vec3, Vec4};
74 pub use crate::time::{Duration, Instant, Time};
75
76 // Parallel types
77 #[cfg(feature = "parallel")]
78 pub use crate::handle::ConcurrentHandleAllocator;
79
80 // Async types
81 #[cfg(feature = "async")]
82 pub use crate::time::async_time;
83}
84
85// Re-export rayon for convenience when parallel feature is enabled
86#[cfg(feature = "parallel")]
87pub use rayon;