Seregon/StratoSDK

StratoSDK is a framework with a declarative approach similar to Flutter/React, written and designed entirely for Rust.

Rust/27.3 KB/No license
crates/strato-core/src/lib.rs
1//! Core functionality for StratoUI framework
2//!
3//! This crate provides the fundamental building blocks for the StratoUI framework,
4//! including state management, event handling, and layout calculations.
5 
6pub mod config;
7pub mod error;
8pub mod event;
9pub mod hot_reload;
10pub mod inspector;
11pub mod layout;
12pub mod logging;
13pub mod plugin;
14pub mod reactive;
15pub mod state;
16pub mod taffy_layout;
17pub mod text;
18pub mod theme;
19pub mod types;
20pub mod ui_node;
21pub mod validated_rect;
22pub mod vdom;
23pub mod widget;
24pub mod window;
25 
26pub use error::{
27 Result, StratoError, StratoResult, TaffyLayoutError, TaffyLayoutResult, TaffyRenderError,
28 TaffyRenderResult, TaffyValidationError, TaffyValidationResult,
29};
30pub use event::{Event, EventHandler, EventResult};
31pub use layout::{Constraints, Layout, LayoutConstraints, LayoutEngine, Size};
32pub use logging::{LogCategory, LogLevel};
33pub use reactive::{Computed, Effect, Reactive};
34pub use state::{Signal, State};
35pub use taffy;
36pub use taffy_layout::{ComputedLayout, DrawCommand, TaffyLayoutManager, TaffyWidget};
37pub use types::{Color, Point, Rect, Transform};
38pub use validated_rect::ValidatedRect;
39 
40/// Re-export commonly used types
41pub mod prelude {
42 pub use crate::{
43 error::{Result, StratoError},
44 event::{Event, EventHandler, EventResult},
45 inspector::{inspector, InspectorConfig, InspectorSnapshot},
46 layout::{Constraints, Layout, Size},
47 logging::LogLevel,
48 reactive::{Computed, Effect},
49 state::{Signal, State},
50 types::{Color, Point, Rect},
51 };
52}
53 
54/// Framework version information
55pub const VERSION: &str = env!("CARGO_PKG_VERSION");
56 
57/// Initialize the core framework
58pub fn init() -> Result<()> {
59 // Initialize logging system with default config
60 let config = config::LoggingConfig::default();
61 if let Err(e) = logging::init(&config) {
62 return Err(StratoError::Initialization {
63 message: format!("Failed to initialize logging: {}", e),
64 context: None,
65 });
66 }
67 
68 // Initialize tracing
69 tracing::info!("StratoUI Core v{} initialized", VERSION);
70 Ok(())
71}
72 
73#[cfg(test)]
74mod tests {
75 use super::*;
76 
77 #[test]
78 fn test_version() {
79 assert!(!VERSION.is_empty());
80 }
81}
82