azul_core/lib.rs
1//! Shared datatypes for azul-* crates
2//!
3//! `azul-core` provides the platform-independent core types used throughout
4//! the Azul toolkit. Key modules include [`dom`] for DOM construction,
5//! [`callbacks`] for event callback types, [`styled_dom`] for the CSSOM,
6//! and [`window`] for OS windowing abstractions.
7//!
8//! This crate depends on [`azul_css`] for CSS property definitions and is
9//! consumed by `azul-layout`, `azul-dll`, and the platform shell crates.
10//! It supports `no_std` environments via `#![cfg_attr(not(feature = "std"), no_std)]`.
11
12#![cfg_attr(not(feature = "std"), no_std)]
13// Lint policy: deny correctness/safety issues, warn on style
14#![deny(unused_must_use)]
15#![warn(clippy::all)]
16#![allow(
17 clippy::non_canonical_partial_ord_impl,
18 clippy::legacy_numeric_constants,
19 clippy::should_implement_trait,
20 clippy::result_unit_err,
21 clippy::ptr_as_ptr,
22 clippy::too_many_arguments,
23 clippy::type_complexity,
24 unused_imports,
25 unused_variables,
26 unused_mut,
27 unused_parens,
28 dead_code,
29 unused_doc_comments,
30 unused_assignments, // compact_cache_builder incremental updates
31 mismatched_lifetime_syntaxes,
32 unexpected_cfgs,
33 unpredictable_function_pointer_comparisons, // intentional in dom callback comparison
34 improper_ctypes_definitions, // xml component fns use Rust fn pointers internally
35 static_mut_refs, // TODO: migrate to OnceLock for Rust 2024
36)]
37
38// `extern crate` + `#[macro_use]` required for `no_std` support:
39// makes `core` and `alloc` macros available without `use` imports.
40#[macro_use]
41extern crate core;
42#[macro_use]
43extern crate alloc;
44#[macro_use]
45extern crate azul_css;
46
47/// Internal macros for `Vec`, `Option`, and callback boilerplate.
48#[macro_use]
49pub mod macros;
50/// Debug logging system with category filtering.
51#[macro_use]
52pub mod debug;
53/// SQL database POD types — `DbValue` + `DbRows` (engine-agnostic). The
54/// `Db` handle + SQLite engine live in `azul_dll` behind `db-sqlite`.
55pub mod db;
56/// Unified `AZ_PROFILE` gate for memory and CPU profiling instrumentation.
57pub mod profile;
58/// Callback types: layout, event, timer, thread, and focus handling.
59#[macro_use]
60pub mod callbacks;
61/// Host-language callback invoker registry — the C-ABI surface managed-FFI
62/// bindings (Lua, Ruby, …) use to register one per-kind invoker + a single
63/// shared releaser, so callbacks can be created via `_createFromHostHandle`
64/// without the host having to generate trampolines for struct-by-value
65/// signatures their FFI library can't handle.
66#[macro_use]
67pub mod host_invoker;
68/// Accessibility types for screen-reader integration (AccessKit).
69pub mod a11y;
70/// DOM construction: `Dom`, `NodeData`, `NodeType`, and the CSS-in-Rust API.
71pub mod dom;
72/// Drag context for text selection, scrollbar, node, and window drags.
73pub mod drag;
74/// Icon provider system for loading icons from fonts, images, or zip packs.
75pub mod icon;
76/// Resource management: font/image loading, caching, and garbage collection.
77pub mod resources;
78/// Text selection and cursor positioning for inline content.
79pub mod selection;
80/// Motion-sensor POD types — `SensorKind` + `SensorReading`.
81/// Stateful manager lives in `azul_layout::managers::sensors`.
82pub mod sensors;
83/// Linear-time DOM diffing for incremental updates.
84pub mod diff;
85/// CSS animation and transition configuration.
86pub mod animation;
87/// Event filtering: mouse, keyboard, window, and synthetic events.
88pub mod events;
89/// Biometric-auth POD types — `BiometricKind` + `BiometricResult` + `BiometricPrompt`.
90/// Stateful manager lives in `azul_layout::managers::biometric`.
91pub mod biometric;
92/// Geolocation POD types — `LocationFix` + `GeolocationProbeConfig`.
93/// Stateful manager lives in `azul_layout::managers::geolocation`.
94pub mod geolocation;
95/// Gamepad POD types — `GamepadId` + `GamepadButton` + `GamepadAxis` +
96/// `GamepadState`. Stateful manager lives in `azul_layout::managers::gamepad`.
97pub mod gamepad;
98/// Camera-capture POD types — `CaptureStreamId` + `CameraConfig` +
99/// `CameraFacing` + `StreamState` + … . The stateful `CameraStream` /
100/// `CameraManager` (which own the shared `ImageRef` texture) live in
101/// `azul_layout::managers::camera`.
102pub mod camera;
103/// Screen-capture POD types — `ScreenCaptureSource` + `ScreenCaptureConfig`.
104/// Symmetric to the camera surface (a "dumb widget" in
105/// `azul_layout::widgets::screencap`); reuses `camera`'s capture status types.
106pub mod screencap;
107/// Video-playback POD types — `VideoConfig` (source URL + autoplay/loop).
108/// Same "dumb widget" architecture (`azul_layout::widgets::video`); decoded
109/// via vk-video into the shared GL texture.
110pub mod video;
111/// Audio POD types — `AudioConfig` (stream format) + `AudioFrame` (interleaved
112/// f32 samples). The unit captured from the mic, played back, and (P8) shared
113/// over UDP. Backend (rodio / cpal / AVAudioEngine / AAudio) lives dll-side.
114pub mod audio;
115/// UDP chunked-message framing (P8): split a >MTU payload into sequenced
116/// datagrams + reassemble them, tolerating reorder + loss. Pure logic the
117/// dll's `Udp` handle builds on; unit-tested here. See `udp_framing.rs`.
118pub mod udp_framing;
119/// Logical and physical coordinate types (`LogicalSize`, `PhysicalPosition`, etc.).
120pub mod geom;
121/// OpenGL context wrappers, shader compilation, and texture cache.
122pub mod gl;
123/// FXAA (Fast Approximate Anti-Aliasing) shader.
124pub mod gl_fxaa;
125/// OpenGL constants (GL 1.1 through GL 4.x).
126pub mod glconst;
127/// GPU value cache for CSS transforms and opacity.
128pub mod gpu;
129/// Hit-test results: which DOM nodes are under the cursor.
130pub mod hit_test;
131/// Type-safe hit-test tag system for compositor integration.
132pub mod hit_test_tag;
133/// Arena-based node tree storage and hierarchy management.
134pub mod id;
135/// System-keyring POD types — `KeyringRequest` + `KeyringResult`.
136/// Stateful manager lives in `azul_layout::managers::keyring`.
137pub mod keyring;
138/// Menu system: context menus, dropdown menus, and menu bars.
139pub mod menu;
140/// CSS property cache for efficient per-node style resolution.
141pub mod prop_cache;
142/// Converts `CssPropertyCache` into compact three-tier numeric cache.
143pub mod compact_cache_builder;
144/// Type-erased, ref-counted smart pointer with runtime borrow checking.
145pub mod refany;
146/// CSS cascade: selector matching, specificity, and property inheritance.
147pub mod style;
148/// `StyledDom` — the result of applying CSS to a DOM tree (the CSSOM).
149pub mod styled_dom;
150/// SVG rendering, path tessellation, and geometric operations.
151pub mod svg;
152/// SVG `d=""` path data parser.
153pub mod svg_path_parser;
154/// Timer, thread, and async task management.
155pub mod task;
156/// 3D transform matrix computation for CSS transforms.
157pub mod transform;
158/// Built-in user-agent default stylesheet.
159pub mod ua_css;
160/// Default font/text constants and small geometry helpers for layout.
161pub mod ui_solver;
162/// Window configuration, input state, and platform-specific options.
163pub mod window;
164/// XML and XHTML parsing for declarative UI definitions.
165pub mod xml;
166/// JSON value types for the C API (no serde dependency).
167pub mod json;
168
169/// Ordered map alias used throughout `azul-core`.
170///
171/// This is backed by `BTreeMap` (not a hash map) because the `core` crate
172/// supports `no_std`, where `HashMap` is unavailable. The webrender crates
173/// define their own `FastHashMap` using `HashMap` + `FxHasher`.
174pub type OrderedMap<T, U> = alloc::collections::BTreeMap<T, U>;
175pub type FastBTreeSet<T> = alloc::collections::BTreeSet<T>;