wasm/lib.rs
1//! Xila WebAssembly runtime and guest API (`wasm`).
2//!
3//! This crate exposes two feature-selected surfaces:
4//!
5//! - **Guest API (`guest` / `default_guest` features, target `wasm32-wasip1`)**:
6//! The `#![no_std]` guest interface linked by Xila WebAssembly applications.
7//! It re-exports `fd_control` for custom VFS descriptor control commands
8//! over `wasi_snapshot_preview1` and, when the `graphics` feature is enabled,
9//! the generated LVGL widget, window, style, layout, file-picker, and event
10//! functions backed by the `host::xila_graphics_call` import, along with
11//! `EventCode` and `EVENT_CLOSE_REQUESTED`.
12//! - **Host runtime (`host` feature)**:
13//! The `wasmi`-based WebAssembly virtual machine executable (`WasmDevice`),
14//! WASI Preview 1 host imports (`WasiContext`, `add_wasi_to_linker`), linear
15//! memory pointer translation (`translation`), and host-side LVGL graphics
16//! call dispatch (`graphics`).
17
18#![no_std]
19
20extern crate alloc;
21
22// Core owns the event contract; the build script copies its source here.
23/// Xila's guest event contract, independent of LVGL's native discriminants.
24/// Keep the event order stable; the host translates at its boundary.
25#[cfg(feature = "graphics")]
26mod graphics_event {
27 include!(concat!(env!("OUT_DIR"), "/event_code.rs"));
28}
29
30#[cfg(feature = "graphics")]
31pub use graphics_event::{EVENT_CLOSE_REQUESTED, EventCode};
32
33#[cfg(feature = "host")]
34mod host;
35
36#[cfg(feature = "host")]
37pub use host::*;
38
39#[cfg(feature = "guest")]
40mod guest;
41
42#[cfg(feature = "guest")]
43pub use guest::*;