Build and run
The SDK includes native/lib and native/bin. Its script tests and builds quickstarts and canonical examples. Standalone apps use KUI_C_SDK or KUI_C_LIB_DIR to locate C ABI dependencies. Check Release and Debug import library paths separately.
pwsh -File build.ps1 -Configuration Release -Output bin
cargo run --release --example hello_worldSafe facade and low-level calls
Common APIs use Result and RAII for native resources. Less common ABI calls remain public in kui::sys. Follow unsafe, handle ownership and UI-thread rules when using them. Do not allow an FFI callback panic to cross the C boundary.
Threads and extensions
UI objects such as Platform, Window, Document and Element must not be sent across threads. Return asynchronous results to the UI thread before updating the DOM. Deploy required Full Profile extensions and media DLLs; Rust crates do not reimplement those backends.
A complete window entry point
This source comes directly from the SDK hello_world example. Build within the package workspace, keeping its modules and helper folders; copying this file alone does not provide its dependencies.
use kui::{Platform, Window, WindowProps};
fn main() -> kui::Result<()> {
let platform = Platform::init()?;
let window = Window::new(&WindowProps {
title: "KUI Rust SDK".into(),
width: 960,
height: 640,
..WindowProps::default()
})?;
let mut document = window.document()?;
document.load_html(
r#"<main style="padding:48px;font-family:sans-serif"><h1>Rust SDK 已接入 KUI</h1><p>此程序仅通过公开 C ABI 工作。</p></main>"#,
)?;
window.show()?;
let _ = platform.run()?;
Ok(())
}
Before building
Use the symptom to narrow the cause before editing.
| Symptom | Check and action |
|---|---|
| Binding or native library missing | Build in the SDK workspace and point to the binding’s packaged native directory. |
| Startup error or frozen UI | Check runtime versions, keep UI calls on the initialization thread and avoid blocking the event loop. |
| Worker result cannot safely update UI | Dispatch through the binding’s main-thread entry point and confirm the window is still alive. |
Something unclear?
Report an issue on this page →