Skip to main content

kozan_platform/
lib.rs

1//! `kozan-platform` — Abstract platform layer for Kozan.
2//!
3//! Like Chrome's `content/` — defines the contract between the engine
4//! and the windowing system. **Zero windowing-backend dependency.**
5//!
6//! The windowing backend (e.g., `kozan-winit`) implements `PlatformHost`
7//! and drives the event loop. This crate provides:
8//! - Abstract types: `WindowId`, `ViewId`, `WindowConfig`
9//! - `PlatformHost` trait: view→main-thread communication
10//! - `ViewEvent` / `LifecycleEvent`: main→view-thread messages
11//! - `ViewThreadHandle` / `ViewContext`: per-view threading model
12//! - `WindowManager<R>`: the brain — routes events, owns pipelines
13//! - `Renderer` / `RenderSurface` traits: GPU backend abstraction
14//!
15//! # Architecture
16//!
17//! ```text
18//! kozan-winit (or any backend)
19//!   ├── implements PlatformHost
20//!   ├── creates OS windows
21//!   ├── passes raw window handles to WindowManager
22//!   └── converts OS events → WindowManager.on_*()
23//!
24//! kozan-platform (this crate — THE BRAIN)
25//!   ├── WindowManager<R: Renderer>: owns all windows + renderer
26//!   ├── WindowPipeline: spawns view + render threads per window
27//!   ├── RenderLoop: compositor + vsync loop
28//!   ├── ViewContext: user-facing API inside view thread
29//!   └── Renderer / RenderSurface traits
30//!
31//! kozan-vello (or any GPU backend)
32//!   ├── implements Renderer + RenderSurface
33//!   └── zero winit knowledge
34//!
35//! kozan-core (engine)
36//!   ├── input/ types (InputEvent, Modifiers, etc.)
37//!   ├── widget/ (FrameWidget, Viewport — future)
38//!   └── dom/, events/, style/
39//! ```
40
41pub mod context;
42pub mod event;
43pub mod host;
44pub mod id;
45pub mod pipeline;
46pub mod renderer;
47pub mod request;
48pub mod time;
49pub mod view_thread;
50pub mod window_manager;
51pub(crate) mod window_state;
52
53pub use context::ViewContext;
54pub use event::{LifecycleEvent, ViewEvent};
55pub use host::PlatformHost;
56pub use id::{ViewId, WindowId};
57pub use pipeline::ViewportInfo;
58pub use pipeline::render_loop::RenderEvent;
59pub use renderer::{RenderParams, RenderSurface, Renderer, RendererError};
60pub use request::WindowConfig;
61pub use view_thread::SpawnError;
62pub use window_manager::{CreateWindowError, WindowCreateConfig, WindowManager};