Expand description
Write a printCAD workbench as a WebAssembly component.
Implement Bench on a type and name it with bench!; build the
crate as a cdylib for wasm32-wasip2. The data the bench and the
app exchange is api (the printcad-bench-api crate); what the app offers
is host. docs/PLUGINS.md in the printCAD repository walks
through a package.
The SDK’s 0.1.x speaks the contract printcad:workbench@0.1, and a
patch release only adds: match the app’s events with a wildcard arm
and fill the contract’s structs with ..Default::default(), and a
package keeps building on every later 0.1.x.
ⓘ
use printcad_bench_sdk::{Bench, api::*, bench};
#[derive(Default)]
struct Hello;
impl Bench for Hello {
fn describe(&self) -> Registration {
Registration { label: "Hello".into(), ..Default::default() }
}
}
bench!(Hello);Re-exports§
pub use bench_api as api;pub use serde_json;
Modules§
- host
- What the app offers a bench.
- panel
- Builders for a declared panel’s blocks: sections with counts and summaries, item lists with values, tags and badges, a filter, a status pill, and the layout around them. Each says what a part of the panel is; printCAD draws it as its own panels draw theirs.
Macros§
- bench
- Make
$bench(aBench) the component’s workbench. - json
- Construct a
serde_json::Valuefrom a JSON literal.
Structs§
- Height
Field - A grid of heights kept as a mesh (simulated material, a terrain):
cols×rowspointspitchapart in x and y fromorigin, each raised by its height, two triangles a cell. Draw it with itshandleinFrame::kept;updatesends only the rectangle that changed.
Enums§
- Value
- Represents any valid JSON value.
Traits§
- Bench
- A workbench. Every method has a default, so a bench implements what it
offers. One value of it lives in the bench’s instance for as long as
the app runs; a job runs in an instance of its own, through
Bench::job.