Wardian docs

Unit converter

Try it

The app runs here in your browser. Nothing you type leaves it. Open it on its own.

Download unit-converter.wardian Import it in Wardian: Settings → Import.

For anyone converting an everyday measurement: temperature, length, mass, US volume, speed, fuel use, pressure, power, food energy, or body mass index. A Wardian module app: 32 conversions, each a WebAssembly function of numbers. There is no page; Wardian reads the module's exports and draws a card for each function, with an input per parameter and a Run button.

Why a module: every conversion takes numbers and returns a number. That is exactly what a module app shows without help, so the whole interface comes from src/lib.rs. No HTML, no JavaScript.

What you put in#

Each function's name says what goes in and what comes out: km_to_miles takes kilometres. Wardian labels the inputs "arg 1", "arg 2", so a function with two inputs names both, in order: bmi_kg_m takes the weight in kilograms first, then the height in metres. Every input is a decimal number; an empty input counts as 0.

GroupFunctionInputUnitAllowed
Temperaturec_to_f, f_to_ca temperature°C, °Fany
c_to_ka temperature°C−273.15 or more
k_to_ca temperatureK0 or more
Lengthkm_to_miles, miles_to_km, m_to_feet, feet_to_m, cm_to_inches, inches_to_cma lengthas namedany
feet_inches_to_cmfeet, then inchesft, inany
Masskg_to_lb, lb_to_kg, g_to_oz, oz_to_ga massas namedany
Volume (US)liters_to_gallons, gallons_to_liters, ml_to_floz, floz_to_mla volumeas namedany
Speedkmh_to_mph, mph_to_kmha speedas namedany
Fuel usempg_to_l_per_100km, l_per_100km_to_mpgfuel useUS mpg, L/100 kmabove 0
Pressurekpa_to_psi, psi_to_kpa, bar_to_psia pressureas namedany
Power and energykw_to_hp, hp_to_kw, kcal_to_kj, kj_to_kcalpower or energyas namedany
Bodybmi_kg_mweight, then heightkg, mweight 0 or more, height above 0
bmi_lb_inweight, then heightlb, inweight 0 or more, height above 0

What it shows#

One number under the card: the converted value, rounded to 4 decimal places (BMI to 1), so 37 °C shows as 98.6 and not 98.60000000000001.

How it behaves#

Layout#

Wardian draws it: one card per function, in alphabetical order of the names, each with its inputs, a Run button (Enter runs it too) and the result. Arrange lets each viewer reorder and hide the cards. Because the host draws the controls, the page rules for field sizes and markup do not apply here; the names, the order and the out-of-range answers are this app's part.

Files#

FileWhat it is
src/lib.rsThe conversions. Each #[no_mangle] pub extern "C" fn becomes a card in Wardian. Unit tests at the end, including the out-of-range answers.
app.wasmThe module Wardian runs, about 2 KB. Built from src/lib.rs.
app.jsonThe title and the description in the app list.
build.shRebuilds app.wasm.

Change it: edit src/lib.rs, run cargo test, run ./build.sh, then wardian check ..

This page is apps/unit-converter/README.md in the repository. Something wrong or missing? Change that file.