Skip to main content

Crate maned

Crate maned 

Source
Expand description

maned — call .mnd scripts in-process.

One entry point in the engine, mnd_request, answers the same request→response contract as maned-serve’s REST API with no socket and no HTTP framing. This crate is the safe face of it (MANEDRS_PLAN.md §4).

let mut scoring = maned::load("scoring.mnd")?;
let result = scoring.run(&serde_json::json!({
    "x": [[2, 0], [0, 2]],
    "w": [[3, 4], [5, 6]],
}))?;
let y = result.tensor("y")?;        // Tensor { shape: [2, 2], data: [...] }

§The library has to be installed first

A .crate cannot ship per-platform binaries, so cargo add maned is not enough: install the maned-capi-$VERSION-$target tarball, or point MANED_LIB_DIR at an unpacked one (§4.5). maned-sys’s build script says so, at length, if it cannot find the library.

§Threads

Script is Send and not Sync: run takes &mut self, so concurrent calls on one handle are impossible and Arc<Script> does not compile. Script::into_shared checks mnd_script_is_routed() and, on a non-routed script, hands back a SharedScript that is Sync and can be called from as many threads as you like with no lock at all (§4.3).

§Non-goals

Windows (the engine’s serve and net layers are POSIX throughout) and cancellation (calls are uninterruptible; see SharedScript::run_async’s documentation, under the tokio feature).

Modules§

multipart
multipart/form-data for the file routes — POST /run and POST /frame.

Structs§

IoSpec
One in:: or out:: entry of the script’s contract, from GET /health.
Response
RoutedScriptError
into_shared() refused: the script routes to a device, and a device channel is single-connection. The script itself is in here — take it back with RoutedScriptError::into_script.
Script
One loaded .mnd script: parsed, linted, inlined, planned and validated once, then answering requests.
ScriptBuilder
Flags for mnd_open. maned::load(path) is builder(path).open().
SharedScript
A script proven non-routed, and therefore callable from many threads at once with no lock.
Tensor
i64 <-> int64_t round-trips losslessly (include/maned/interp/value.h:23-24).

Enums§

Error

Functions§

abi_version
The ABI generation of the library actually linked in.
add_search_path
Append a directory to search_path.
builder
Start building a script handle: flags, then open.
find
Find a script by name: $MANEDPATH → search_path → CWD → ./mnd/, identical to manedpy.
live_handles
How many script handles shutdown would close right now.
load
Load a script from a literal path.
search_path
The process-global extra directories find searches, after $MANEDPATH and before the working directory.
set_kernel_threads
Process-global interpreter worker-thread count (src/interp/parallel.cpp:16, one std::atomic<int>; setter at :24).
set_search_path
Replace search_path wholesale.
shutdown
Close every live Script handle.
version
The engine version of the library actually linked in (“1.2.3”).