Skip to main content

compose_rust/
lib.rs

1#![deny(unsafe_op_in_unsafe_fn)]
2
3pub mod asset;
4pub mod boundary;
5/// Generated JNI shims. Compiled only for Android, where the Host is a cdylib that the
6/// Kotlin Activity loads.
7#[cfg(target_os = "android")]
8#[path = "boundary_jni.gen.rs"]
9mod boundary_jni;
10/// Generated wasm shims. Compiled only for the browser, where the page owns the loop and
11/// the Renderer's module owns the one linear memory both halves read.
12#[cfg(target_family = "wasm")]
13#[path = "boundary_wasm.gen.rs"]
14mod boundary_wasm;
15pub mod brush;
16/// The rule the code colours of the two systems without a code editor scheme are derived
17/// by. Only the tests run it: the values themselves are literals in the token tables.
18#[cfg(test)]
19mod code_colours;
20pub mod contrast;
21#[cfg(target_family = "wasm")]
22#[doc(hidden)]
23pub use boundary_wasm::web_start as __web_start;
24#[doc(hidden)]
25pub mod codegen;
26pub mod design;
27pub mod drawing;
28mod extensions;
29pub mod highlight;
30pub mod input;
31pub mod message;
32pub mod notification;
33pub mod palette;
34pub mod protocol;
35pub mod runtime;
36pub mod schema;
37pub mod spans;
38pub mod theme;
39pub mod tokens;
40pub mod window;
41
42pub use asset::asset;
43pub use boundary::{
44    Host, LaunchBuilder, MutationBatch, RendererApi, RuntimeFactory, demo_theme, demo_theme_for,
45    install_renderer_api, launch_runtime, request_frame_from_worker,
46};
47pub use brush::{Brush, Stop, brush};
48pub use design::design_system;
49pub use drawing::{DrawCommand, DrawList, DrawListBuilder};
50pub use input::{FileDrop, KeyEvent, RangeRequest};
51pub use message::{Message, show_message};
52pub use notification::{
53    Notification, NotificationActivation, NotificationSender, notification_permission,
54    request_notification_permission, withdraw_notification,
55};
56pub use palette::{Palette, PaletteViolation};
57pub use runtime::{Batch, Runtime};
58pub use schema::{
59    Alignment, Arrangement, AssetKind, ButtonVariant, Chrome, Color, ColorRole, ColorScheme,
60    DesignSystem, EventPayload, IconRole, Key, LoopMode, MaterialRole, MessageDuration, Modifier,
61    MotionRole, NotificationImportance, NotificationPermission, NotificationPresentation, Paint,
62    PropertyKind, SCHEMA_HASH, Selection, ShapeRole, SpaceRole, TextAlign, TextOverflow, Theme,
63    TileMode, TypeRole, WidgetKind, WindowHeightClass, WindowSizeClass,
64};
65pub use theme::ThemeHandle;
66pub use window::{NodeSize, WindowSize, node_size, window_size};
67
68/// Declares the entry point an iOS application starts at.
69///
70/// iOS is the one platform where the application is the library: the renderer is a
71/// Kotlin/Native archive and the two are linked into a single executable, so there is no
72/// Activity to load anything and no page to fetch anything. What there is instead is a
73/// `main`, and a `main` in an application bundle has to be C, so this exports the launch
74/// under a name that C can call.
75///
76/// ```ignore
77/// compose_rust::ios_main!(launch);
78/// ```
79///
80/// The export exists only in a build for iOS. Anywhere else nothing calls it, and an
81/// unconditional export would collide with the same name in every other application
82/// linked into one binary, which is what a benchmark that drives several of them does.
83#[macro_export]
84macro_rules! ios_main {
85    ($launch:path) => {
86        #[cfg(target_os = "ios")]
87        #[unsafe(no_mangle)]
88        pub extern "C" fn compose_rust_ios_main() -> i32 {
89            $launch();
90            0
91        }
92    };
93}