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-datafor the file routes —POST /runandPOST /frame.
Structs§
- IoSpec
- One
in::orout::entry of the script’s contract, fromGET /health. - Response
- Routed
Script Error 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 withRoutedScriptError::into_script.- Script
- One loaded
.mndscript: parsed, linted, inlined, planned and validated once, then answering requests. - Script
Builder - Flags for
mnd_open.maned::load(path)isbuilder(path).open(). - Shared
Script - A script proven non-routed, and therefore callable from many threads at once with no lock.
- Tensor
i64<->int64_tround-trips losslessly (include/maned/interp/value.h:23-24).
Enums§
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
shutdownwould close right now. - load
- Load a script from a literal path.
- search_
path - The process-global extra directories
findsearches, after$MANEDPATHand before the working directory. - set_
kernel_ threads - Process-global interpreter worker-thread count
(
src/interp/parallel.cpp:16, onestd::atomic<int>; setter at:24). - set_
search_ path - Replace
search_pathwholesale. - shutdown
- Close every live
Scripthandle. - version
- The engine version of the library actually linked in (“1.2.3”).