FORGE KUI / docs

Integrate the Rust SDK

Use kui and kui-sys with the Windows x64 MSVC toolchain.

Version 3.61.7

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.

powershell
pwsh -File build.ps1 -Configuration Release -Output bin
cargo run --release --example hello_world

Safe 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.

rust
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.

Before building
SymptomCheck and action
Binding or native library missingBuild in the SDK workspace and point to the binding’s packaged native directory.
Startup error or frozen UICheck runtime versions, keep UI calls on the initialization thread and avoid blocking the event loop.
Worker result cannot safely update UIDispatch through the binding’s main-thread entry point and confirm the window is still alive.