Crates.io | aws-mumu |
lib.rs | aws-mumu |
version | 0.1.0 |
created_at | 2025-08-15 12:18:54.507997+00 |
updated_at | 2025-08-15 12:18:54.507997+00 |
description | aws-mumu is a plugin for the mumu ecosystem |
homepage | https://lava.nu11.uk |
repository | https://gitlab.com/tofo/aws-mumu |
max_upload_size | |
id | 1796655 |
size | 147,812 |
A lightweight extension that adds Amazon S3 capabilities to the MuMu runtime: credentials sessions, bucket creation, and object fetching (to file or as a streaming iterator). Built-in SigV4 signing, friendly error surfaces, and examples for both real S3 and S3‑compatible endpoints (e.g., LocalStack).
Language:RustRuntime:MuMuAuth:SigV4Transport:reqwest (blocking)
Table of contents
The MuMu loader looks for a dynamic library named libmumu
# from the repository root
cargo build --release
# point MuMu to the build directory (adjust for your OS/shell)
export MUMU_PLUGIN_PATH="$(pwd)/target/release"
# REPL (verbose is handy while developing)
mumu --verbose
# or (depending on install)
lava-mumu --verbose
# Run a .mu script
mumu examples/s3/fetch.mu
extend("aws")
extend("process") // to read environment variables
credentials = aws:credentials([
accessKeyId: process:env("AWS_ACCESS_KEY_ID"),
secretAccessKey: process:env("AWS_SECRET_ACCESS_KEY"),
region: process:env("AWS_REGION"),
// Optional: S3-compatible endpoint (e.g., LocalStack)
// endpoint: "http://localhost:4566"
])
Return value: a short session id string — pass this to other AWS calls.
extend("aws")
extend("process")
extend("test") // just for test:diceware()
credentials = aws:credentials([
accessKeyId: process:env("AWS_ACCESS_KEY_ID"),
secretAccessKey: process:env("AWS_SECRET_ACCESS_KEY"),
region: process:env("AWS_REGION"),
endpoint: "http://localhost:4566" // optional
])
result = aws:s3:create_bucket([
credentials: credentials,
bucket: test:diceware()
])
slog(result) // → [ok: true, bucket: "..."] or [ok: false, error: "..."]
extend("aws")
extend("process")
credentials = aws:credentials([
accessKeyId: process:env("AWS_ACCESS_KEY_ID"),
secretAccessKey: process:env("AWS_SECRET_ACCESS_KEY"),
region: process:env("AWS_REGION")
])
result = aws:s3:fetch([
credentials: credentials,
bucket: "my-bucket",
key: "path/to/object.png",
// use either:
// path: "/tmp/object.png",
folder: "/tmp/s3-downloads" // filename inferred from key
])
slog(result) // → [ok: true, path: "/tmp/s3-downloads/object.png"]
Omit path/folder to get an InkIterator yielding chunks: { chunk: IntArray }.
extend("aws")
extend("file")
extend("process")
credentials = aws:credentials([
accessKeyId: process:env("AWS_ACCESS_KEY_ID"),
secretAccessKey: process:env("AWS_SECRET_ACCESS_KEY"),
region: process:env("AWS_REGION")
])
stream = aws:s3:fetch([
credentials: credentials,
bucket: "my-bucket",
key: "large-object.bin"
])
file:write("/tmp/large-object.bin", stream)
Chunks are read in up to 8192‑byte blocks and delivered as signed ints (0–255) in an IntArray. The iterator finishes naturally when the stream ends.
More streaming examples: examples/s3/fetch-stream.mu, examples/s3/fetch-stream-map.mu, examples/s3/fetch-multi.mu.
aws:credentials(opts)
→ session_id:stringKey | Type | Required | Notes |
---|---|---|---|
accessKeyId |
string | Yes | AWS access key id |
secretAccessKey |
string | Yes | AWS secret |
region |
string | Yes | e.g., us-east-1 |
endpoint |
string | No | S3‑compatible endpoint (LocalStack, MinIO w/ S3 API, etc.) |
Validates inputs and stores an in‑memory session. Returns a short session id. On failure, the dynamic wrapper surfaces an error object:
[ok: false, error: "aws:credentials: ..."]
aws:s3:create_bucket(opts)
→ { ok, bucket? , error? }Key | Type | Required | Notes |
---|---|---|---|
credentials |
string | Yes | Session id from aws:credentials |
bucket |
string | Yes | Bucket name |
On success returns [ok: true, bucket: "…"]; on error returns [ok: false, error: "…"].
aws:s3:fetch(opts)
→ InkIterator or { ok, path? , error? }Key | Type | Required | Notes |
---|---|---|---|
credentials |
string | Yes | Session id |
bucket |
string | Yes | Bucket name |
key |
string | Yes | Object key |
path |
string | No | Full destination path (direct download) |
folder |
string | No | Destination directory (filename inferred) |
path
or folder
is provided → downloads the object and returns [ok: true, path: "..."].{ chunk: IntArray }
.LOCAL/
src/
functions/
sigv4.rs
register/
credentials.rs
s3_create_bucket.rs
s3_fetch.rs
hello.rs
examples/
s3/
create-bucket.mu
fetch.mu
fetch-multi.mu
fetch-stream.mu
fetch-stream-map.mu
REMOTE/ (MuMu engine; vendored)
src/
parser/... # lexer, parser, interpreter, eval helpers, etc.
modules/... # extend, compose/pipe, slog/sput, ink, include, type
The vendored MuMu engine includes improvements for λ by‑reference semantics, composition, numeric coercions, REPL input, autocompletion, and statement write‑through to reference cells.
Run LocalStack with S3 enabled (e.g., via Docker).
Use test credentials and set
endpoint
in
aws:credentials
:
credentials = aws:credentials([
accessKeyId: "test",
secretAccessKey: "test",
region: "us-east-1",
endpoint: "http://localhost:4566"
])
Use the same APIs as you would for AWS.
“no session with id …” — The session id is missing or stale. Call aws:credentials again and reuse its return value.
“AWS error status …” — Check bucket permissions, region, and the exact bucket/key. For S3‑compatible endpoints ensure the endpoint is set in aws:credentials.
Plugin not found
— Ensure
MUMU_PLUGIN_PATH
includes the directory with the compiled library. The loader also searches near the MuMu binary and common system locations:
MuMu engine files reference the MIT license in headers. If this plugin has a separate license, consult the repository’s LICENSE. Example files are provided for educational use.
Thanks to the MuMu contributors for the runtime, REPL, and libraries. This plugin follows MuMu’s dynamic function conventions (extend("aws")) and uses InkIterator for streaming downloads.
© 2025 MuMu × AWS Plugin