Get started – Rust
fuaran-ui (the Rust crate) is the dual-role host: a headless backend /
edge / embedded implementation of the canonical wire format and a
browser-native wasm32 client. It is stdlib-only, and models the closed wire
vocabularies as native enums: a new node kind is a compile-time-exhaustive
match, not a runtime branch.
Install
cargo add fuaran-ui
The crate publishes to crates.io as fuaran-ui; the repository is
fuaran-rs (the repo-name / crate-name split is common in Rust), and the import
path is fuaran_rs.
Author a tree
Kinds are typed enum variants with per-kind spec structs; a TextSource::Literal
is a bare text value. Unset stylistic facets come from Default::default().
use fuaran_rs::wire::{
encode_node, Accessibility, BoxLayout, BoxRole, BoxSpec, HeadingSpec,
HeadingVariant, MarkdownSpec, Node, NodeKind, TextSource,
};
let tree = Node {
id: "root".into(),
kind: NodeKind::Box(BoxSpec {
children: vec![
Node {
id: "title".into(),
kind: NodeKind::Heading(HeadingSpec {
level: 2,
text: TextSource::Literal("Channel performance".into()),
variant: HeadingVariant::Standard,
}),
state: Default::default(),
style: Default::default(),
accessibility: None,
},
Node {
id: "note".into(),
kind: NodeKind::Markdown(MarkdownSpec {
text: TextSource::Literal("**Hello** from a Fuaran tree.".into()),
}),
state: Default::default(),
style: Default::default(),
accessibility: None,
},
],
heading: None,
layout: BoxLayout::Auto,
role: BoxRole::Dashboard,
}),
state: Default::default(),
style: Default::default(),
accessibility: Some(Accessibility { role: Some("main".into()), ..Default::default() }),
};
Encode to canonical wire JSON
let wire: String = encode_node(&tree);
// canonical JSON – byte-identical to the F#, TypeScript, and Python hosts
Render – headless or in the browser
- Headless / edge –
fuaran_rs::renderproduces server-side HTML from a tree, the same static-first output the other backend hosts emit. - Browser-native (WASM) – build the client module with
cargo build --target wasm32-unknown-unknown --release, then instantiate it from the thin JS loader:loadFuaran(wasmUrl)→createSession(exports, tree)→session.mount(el)renders the tree into the DOM and drives interactions client-side. One codec, one apply engine, compiled to WebAssembly.
The tree you just built
Rendered by this very site from the exact JSON encode_node produces – with a
one-click link into the playground:
Channel performance
Hello from a Fuaran tree.
{"accessibility":{"role":"main"},"id":"root","kind":{"$type":"Box","children":[{"id":"title","kind":{"$type":"Heading","level":2,"text":"Channel performance","variant":"Standard"}},{"id":"note","kind":{"$type":"Markdown","text":"**Hello** from a Fuaran tree."}}],"layout":{"$type":"Auto"},"role":"Dashboard"}}
Next
- Bind it natively – the crate builds a C-ABI
staticlibthat the native Swift and Kotlin surfaces link. - Mutate it as data –
fuaran_rs::ops::applyfolds typed tree-ops over a tree instead of rebuilding it. - On another stack? The same tree authors in F#, TypeScript, Python, or Go – byte-identical on the wire.
- See the component reference and the guide.