| Crates.io | std-mumu |
| lib.rs | std-mumu |
| version | 0.3.0-rc.8 |
| created_at | 2025-08-12 13:04:47.220882+00 |
| updated_at | 2025-10-15 23:22:22.162888+00 |
| description | Standard input/output tools for MuMu/Lava |
| homepage | |
| repository | https://gitlab.com/tofo/std-mumu |
| max_upload_size | |
| id | 1791972 |
| size | 56,195 |
Standard input/output & a deep pretty-printer for the Lava/MuMu runtime.
Crate: std-mumu
Repository: https://gitlab.com/tofo/std-mumu
License: MIT OR Apache-2.0 (dual)
Engine compatibility: core-mumu = 0.9.0-rc.4 (host and wasm builds)
std-mumu exposes a compact “std” surface for Lava/MuMu scripts:
std:put(x) – print without a trailing newline (drains iterators).std:log(x) – print with a trailing newline (drains iterators).std:deep(x) – emit a deep, single-line, MuMu-ish representation and return x.std:input([prompt]) – optional prompt, then read a single line from stdin (host only).std:input_iter() – a line iterator over stdin (host only).format(options, data) – minimal formatter; prints and returns data unchanged. Supports partial application and _ placeholders.Works when dynamically loaded at runtime (extend("std")) and when statically registered in a host.
extend("std")
std:log("Hello, Lava!") // prints with newline
std:put("no newline"); std:put("\n")
// Deep printer – compact, escaped, single line
std:deep([a: 1, b: ["x", "y"], c: [1.0, 2.5]])
// Read a line (host/native builds)
std:put("Your name: ")
name = std:input()
std:log("Hi " + name + "!")
Iterator draining (blocking):
extend("std")
// 'step' is provided by the core host; this prints 1, 2, 3 each on its own line.
std:log(step(1,4))
Minimal formatter:
extend("std")
// Deep vs shallow
format([deep:true], [a:[1,2], b:"x"])
format([deep:false], [a:[1,2], b:"x"])
// Quote strings in shallow mode (to see spaces/tabs/newlines)
format([deep:false, quote_strings:true], " hi\t")
// Prefix / suffix / newline control
format([prefix:"=> "], 42) // "=> 42\n"
format([suffix:" ;"], 42) // "42 ;\n"
format([newline:false], 42) // "42"
std:put/std:logdrain iterators synchronously. Use the coreslog/sputnon‑blocking pollers when you need background progress in a REPL/UI loop.
format APIformat(options, data) -> data
A very small option set — no trees, no frames, no colors, no wrapping:
deep (bool, default true) — deep, single‑line representation (quotes + escapes for strings).false, use a shallow form similar to std:put.newline (bool, default true) — print with newline; false prints without \n.prefix (string, default "") — prepend once to the first line.suffix (string, default "") — append once at the end.quote_strings (bool, default false) — when deep:false, quote/escape string leaves so spaces/tabs/newlines are visible. (Deep mode already quotes.)Partial application & _ placeholders are supported:
format(_) → returns a function expecting (options, data)format(opts) → returns a function expecting dataformat(_, data) → returns a function expecting optionsformat(opts, data) → formats immediatelyAll legacy options (tree view, colors, numbering, frame, wrapping, timestamps, help, etc.) were removed for simplicity.
std-mumu builds for both native hosts and wasm targets. Input is intentionally stubbed on the web:
| Function | Native (host) | Web/wasm (browser) |
|---|---|---|
std:input |
✅ reads from stdin |
❌ error: std:input is unavailable in this build |
std:input_iter |
✅ line iterator over stdin |
❌ error: std:input_iter is unavailable |
std:put |
✅ print + push to print buffer | ✅ print buffer updated |
std:log |
✅ print newline + push buffer | ✅ print buffer updated |
std:deep |
✅ deep printer | ✅ deep printer |
format |
✅ minimal formatter | ✅ formatter |
Dynamic (preferred): the shared library exports Cargo_lock. Hosts that support extend("…") can load the plugin at runtime:
extend("std")
std:log("OK")
format([deep:false], [a:1, b:[2,3]])
Static: hosts can call register_all(interp) to make the functions available without dynamic loading.
Dual-licensed under either of:
LICENSELICENSEYou may choose either license.