StratoSDK is a framework with a declarative approach similar to Flutter/React, written and designed entirely for Rust.
| 1 | //! StratoSDK - A lightweight, secure, and reactive UI framework |
| 2 | //! |
| 3 | //! StratoSDK provides a modern, declarative approach to building user interfaces |
| 4 | //! with a focus on performance, security, and developer experience. |
| 5 | |
| 6 | pub use strato_core; |
| 7 | pub use strato_platform; |
| 8 | pub use strato_widgets; |
| 9 | |
| 10 | // Re-export the new granular initialization system |
| 11 | pub use strato_platform::init::{ |
| 12 | get_text_renderer, init_all, init_with_config, is_initialized, InitBuilder, InitConfig, |
| 13 | }; |
| 14 | |
| 15 | use strato_core::Result; |
| 16 | |
| 17 | /// Unified prelude module that exports all commonly used types |
| 18 | pub mod prelude { |
| 19 | pub use strato_core::prelude::*; |
| 20 | pub use strato_platform::{Application, ApplicationBuilder, Window, WindowBuilder}; |
| 21 | pub use strato_widgets::prelude::*; |
| 22 | } |
| 23 | |
| 24 | /// Legacy initialization function - now uses the new granular system |
| 25 | /// |
| 26 | /// This function is kept for backward compatibility but internally uses |
| 27 | /// the new InitBuilder system with default configuration. |
| 28 | /// |
| 29 | /// For better control over initialization, use InitBuilder directly: |
| 30 | /// ```rust |
| 31 | /// use strato_sdk::{InitBuilder, InitConfig}; |
| 32 | /// |
| 33 | /// fn main() -> Result<(), Box<dyn std::error::Error>> { |
| 34 | /// let config = InitConfig { |
| 35 | /// skip_problematic_fonts: true, |
| 36 | /// max_font_faces: Some(50), |
| 37 | /// ..Default::default() |
| 38 | /// }; |
| 39 | /// |
| 40 | /// InitBuilder::new() |
| 41 | /// .with_config(config) |
| 42 | /// .init_all()?; |
| 43 | /// Ok(()) |
| 44 | /// } |
| 45 | /// ``` |
| 46 | #[deprecated( |
| 47 | since = "0.2.0", |
| 48 | note = "Use InitBuilder for better control over initialization" |
| 49 | )] |
| 50 | pub fn init_all_legacy() -> Result<()> { |
| 51 | strato_core::init()?; |
| 52 | strato_widgets::init()?; |
| 53 | strato_platform::init() |
| 54 | .map_err(|e| strato_core::StratoError::platform(format!("Platform init failed: {}", e)))?; |
| 55 | Ok(()) |
| 56 | } |
| 57 | |
| 58 | /// Version information |
| 59 | pub const VERSION: &str = env!("CARGO_PKG_VERSION"); |
| 60 | |
| 61 | #[cfg(test)] |
| 62 | mod tests { |
| 63 | use super::*; |
| 64 | |
| 65 | #[test] |
| 66 | fn test_version() { |
| 67 | assert!(!VERSION.is_empty()); |
| 68 | } |
| 69 | |
| 70 | #[test] |
| 71 | fn test_init_all() { |
| 72 | // This test ensures init_all doesn't panic |
| 73 | let result = init_all(); |
| 74 | assert!(result.is_ok()); |
| 75 | } |
| 76 | } |
| 77 |