pub unsafe fn interpreter(
st: &mut State,
start: Utf8Iter<'_>,
io: Arc<Mutex<IOStreams>>,
ll: LogLevel,
kill: Option<&Receiver<()>>,
restrict: bool,
) -> Result<ExecResult>Expand description
Interpreter entry point, executes ADC commands to modify state.
§Arguments
st: State struct to work on, modified in-placestart: Initial commands to runio: Bundle of IO stream handlesio.0: Input, read by ? one line at a timeio.1: Output, written to by printing commandsio.2: Error messages, one per line
ll: Level of verbosity forio.2kill: Receiver for a kill signal from a parent thread, effect is practically immediate.Some(_)will also enablerestrict.restrict: Restricted mode switch, enable for untrusted input. Iffalse, the interpreter may read/write files and execute OS commands, subject to any OS-level permissions.
§Errors
Any IO errors (except those specified here) that arise when accessing the IOStreams are returned early, aborting the interpreter.
This will result in an incomplete, although internally consistent, State. Keep that possibility to a minimum when preparing custom IOStreams.
§Safety
If built without the no_os feature (default), passing kill = None and restrict = false enables OS interactions that are fundamentally unsound in multithreaded contexts.
Simultaneously/asynchronously executing multiple instances of this function with said arguments is Undefined Behavior. Do not rely on known values of st and start for safety.
Alternatively, interpreter_no_os provides a safe wrapper.