Skip to content

lynaghk/eui

Repository files navigation

Embedded UI generator

Generate an HTML UI at compile-time which can display and edit a single rust struct.

This is a personal research project only. See these two articles for background context:

install / run

./script/run_dev.sh

roadmap

x control a single LED via editing an rgb struct with <input type=”numeric” min=”0” max=”255”> x add two-variant enum, Off and On(RGB{…})

usable entirely through crate

implementation options

JSON Schema generated on rust types via https://docs.rs/schemars/latest/schemars/ then generate UI

JSONSchema discussion of form generation use case: https://github.com/orgs/json-schema-org/discussions/70

reflecting on how serde / bincode would pack a type: https://crates.io/crates/serde-reflection

postcard + schema? jamesmunns/postcard#92

similar-ish idea in Rust: UI controls defined in firmware for a web UI: https://github.com/spookyvision/embedded-web-ui

log

2024 Jan 5 back to CLJS

Frontend Rust didn’t spark joy, so I’m going to go back to CLJS. I want everything to be transparent from the consumer perspective, though — so I need to find a workflow that compiles all of the cljs, sass, etc. in advance and Just Works from Cargo. I’m not sure if that’s really possible though (because I need to compile the consumer’s code), so the best I might be able to do is a template UI/ folder that you copy/paste into your project, then tweak to reference your data definitions, etc.

Hmm, if I lean into copy/paste, though, then why not just have the consumer compile the cljs too? They can mess with the source if they want… I’m 35, I should be okay with copy/paste by now.

Well, downside is additional compilation time and potential dependency hell around CLJS / SASS. Ugh.

I could try and lose trunk and just use wasm without bindgen. Then the basic CLJS <-> WASM Rust API is just a few things:

  • schema (JSON constant)
  • validate field (JSON -> string)
  • validate message (JSON -> string)
  • send (JSON -> void)

hmm, an even easier approach would be to just have generic JS on the frontend and do all validation, etc. on the backend server. Infra would be simpler too, it’d look more like my splot library where you just import the crate and parameterize with your own types.

Let’s have a go.

2023 Dec 13 Look at rust WASM frameworks

Dioxus: failed to build their cli tool on my machine (linking error related to libgit), it had a gazillion deps anyway. I had to dig through the source to figure out that it was trying to mount to a DOM node with ID “main”; doesn’t seem like they’re into any sort of minimal / modular thing. Docs say a minimal build is 70kb but I can’t get lower than 287 kB WASM size via trunk

Sycamore: Just worked, 84kB WASM. Built on signals/reactivity. Seems to have a less experienced main author.

Leptos: seems pretty popular, but devs prefer nightly rust and I couldn’t get their example signals stuff working on stable. Simple hello world, 45kB WASM. Seems like a winner.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published