Skip to main content

Crate kozan_platform

Crate kozan_platform 

Source
Expand description

kozan-platform — Abstract platform layer for Kozan.

Like Chrome’s content/ — defines the contract between the engine and the windowing system. Zero windowing-backend dependency.

The windowing backend (e.g., kozan-winit) implements PlatformHost and drives the event loop. This crate provides:

  • Abstract types: WindowId, ViewId, WindowConfig
  • PlatformHost trait: view→main-thread communication
  • ViewEvent / LifecycleEvent: main→view-thread messages
  • ViewThreadHandle / ViewContext: per-view threading model
  • WindowManager<R>: the brain — routes events, owns pipelines
  • Renderer / RenderSurface traits: GPU backend abstraction

§Architecture

kozan-winit (or any backend)
  ├── implements PlatformHost
  ├── creates OS windows
  ├── passes raw window handles to WindowManager
  └── converts OS events → WindowManager.on_*()

kozan-platform (this crate — THE BRAIN)
  ├── WindowManager<R: Renderer>: owns all windows + renderer
  ├── WindowPipeline: spawns view + render threads per window
  ├── RenderLoop: compositor + vsync loop
  ├── ViewContext: user-facing API inside view thread
  └── Renderer / RenderSurface traits

kozan-vello (or any GPU backend)
  ├── implements Renderer + RenderSurface
  └── zero winit knowledge

kozan-core (engine)
  ├── input/ types (InputEvent, Modifiers, etc.)
  ├── widget/ (FrameWidget, Viewport — future)
  └── dom/, events/, style/

Re-exports§

pub use context::ViewContext;
pub use event::LifecycleEvent;
pub use event::ViewEvent;
pub use host::PlatformHost;
pub use id::ViewId;
pub use id::WindowId;
pub use pipeline::ViewportInfo;
pub use pipeline::render_loop::RenderEvent;
pub use renderer::RenderParams;
pub use renderer::RenderSurface;
pub use renderer::Renderer;
pub use renderer::RendererError;
pub use request::WindowConfig;
pub use view_thread::SpawnError;
pub use window_manager::CreateWindowError;
pub use window_manager::WindowCreateConfig;
pub use window_manager::WindowManager;

Modules§

context
View context — the user-facing API inside a view thread.
event
View event — the top-level message type sent to view threads.
host
Platform host — abstract interface from view threads to the main thread.
id
Platform-level identifiers.
pipeline
Window pipeline — per-window view + render thread orchestration.
renderer
Renderer abstraction — the contract between platform and GPU backend.
request
Window configuration — settings for creating new windows.
time
View-thread async timers — sleep, interval, timeout.
view_thread
View thread types — handle and errors.
window_manager
Window manager — owns all windows, routes events, holds the renderer.