Skip to main content

blinc_platform/
lib.rs

1//! Blinc Platform Abstraction Layer
2//!
3//! This crate provides platform-agnostic traits and types for windowing,
4//! input handling, and application lifecycle management.
5//!
6//! # Architecture
7//!
8//! The platform abstraction is built around three main traits:
9//!
10//! - [`Platform`] - The top-level platform abstraction
11//! - [`Window`] - Window management and properties
12//! - [`EventLoop`] - Event handling and application lifecycle
13//!
14//! # Platform Implementations
15//!
16//! - `blinc_platform_desktop` - Desktop platforms (macOS, Windows, Linux) using winit
17//! - `blinc_platform_android` - Android using NDK
18//! - `blinc_platform_ios` - iOS using UIKit (planned)
19//!
20//! # Example
21//!
22//! ```ignore
23//! use blinc_platform::*;
24//! use blinc_platform_desktop::DesktopPlatform;
25//!
26//! fn main() -> Result<(), PlatformError> {
27//!     let platform = DesktopPlatform::new()?;
28//!     let event_loop = platform.create_event_loop()?;
29//!
30//!     event_loop.run(|event, window| {
31//!         match event {
32//!             Event::Frame => {
33//!                 // Render frame
34//!             }
35//!             Event::Window(WindowEvent::CloseRequested) => {
36//!                 return ControlFlow::Exit;
37//!             }
38//!             _ => {}
39//!         }
40//!         ControlFlow::Continue
41//!     })
42//! }
43//! ```
44
45pub mod assets;
46mod error;
47mod event;
48mod input;
49mod platform;
50mod window;
51
52// Re-export all public types
53pub use error::{PlatformError, Result};
54pub use event::{ControlFlow, Event, EventLoop, LifecycleEvent, WindowEvent};
55pub use input::{
56    InputEvent, Key, KeyState, KeyboardEvent, Modifiers, MouseButton, MouseEvent, ScrollPhase,
57    TouchEvent,
58};
59pub use platform::Platform;
60pub use window::{Cursor, Window, WindowConfig};
61
62// Re-export commonly used asset types
63pub use assets::{AssetLoader, AssetPath, FilesystemAssetLoader};
64
65/// Prelude module for convenient imports
66pub mod prelude {
67    pub use crate::assets::{
68        asset_exists, load_asset, load_asset_string, AssetLoader, AssetPath, FilesystemAssetLoader,
69    };
70    pub use crate::error::{PlatformError, Result};
71    pub use crate::event::{ControlFlow, Event, EventLoop, LifecycleEvent, WindowEvent};
72    pub use crate::input::{
73        InputEvent, Key, KeyState, KeyboardEvent, Modifiers, MouseButton, MouseEvent, ScrollPhase,
74        TouchEvent,
75    };
76    pub use crate::platform::Platform;
77    pub use crate::window::{Cursor, Window, WindowConfig};
78}