pub struct Session { /* private fields */ }Expand description
Per-channel evaluator. Owns mutable state across forms (defun-defined symbols
persist between requests in the same session via SymbolTable; the wasm
ModuleCache reuses compilations of structurally identical forms) and an
interrupt handle that cooperatively short-circuits the next form on demand.
Eval pipeline: nomiscript::Compiler::compile_with_mode(Eval) emits a
module exporting nomi-eval; the form’s final value rides the function’s
(ref null any) return slot and the host walks it into an EvalValue
via decode_eval_result.
Implementations§
Source§impl Session
impl Session
pub fn new(ctx: ScriptCtx) -> Result<Self, SessionError>
pub fn ctx(&self) -> &ScriptCtx
pub fn interrupt_handle(&self) -> InterruptHandle
Sourcepub fn completions(&self, prefix: &str) -> Vec<String>
pub fn completions(&self, prefix: &str) -> Vec<String>
Symbol names completing prefix, sorted and deduplicated, for the SLYNK
completion rex (M-x sly-complete-symbol / mREPL TAB). The reader folds
symbols with make_ascii_uppercase at read time, so the match uppercases
the prefix the SAME way (ASCII-only — matching the reader, not full
Unicode) and returns the canonical name (it re-reads identically). Skips
(SETF …) setf-place names and compiler-internal $… / __… symbols —
none are head symbols a user types. An empty prefix lists every
completable symbol.
Sourcepub fn epoch_bumper(&self) -> EpochBumper
pub fn epoch_bumper(&self) -> EpochBumper
Cooperative cancel handle for an in-flight nomi-eval. Clone
and hand to the transport layer: when the client sends a
cancel signal (e.g. emacs C-g), call .bump() and the
awaiting evaluation traps with EngineError::EpochInterrupt,
surfacing on the wire as (:error (:code interrupted ...)).
Sourcepub fn cache_size(&self) -> Result<usize, EngineError>
pub fn cache_size(&self) -> Result<usize, EngineError>
Number of pre-compiled wasm modules currently cached.
Used by tests to confirm the phase-4 pre-warm step ran and
that subsequent handle_form calls of cached forms don’t
trigger a cold compile.
pub async fn handle_form(&mut self, frame: &str) -> String
Sourcepub async fn handle_request(&mut self, source: &str) -> EvalOutcome
pub async fn handle_request(&mut self, source: &str) -> EvalOutcome
Structured eval of a single bare form (not an envelope frame): clears
the output buffer, runs the form, and returns the captured script output
alongside the typed value/error payload. The SLYNK mREPL uses this so it
can render :write-string (output) and :write-values /
:evaluation-aborted (payload) separately. handle_form is unchanged.
Sourcepub async fn handle_file(&mut self, path: &str) -> EvalOutcome
pub async fn handle_file(&mut self, path: &str) -> EvalOutcome
Reads path, evaluates every top-level form in source order (state —
defuns etc. — accumulates across forms, like the sshd channel), and
returns a short summary. Powers SLY’s M-x sly-load-file
(slynk:load-file). Captured output across all forms is returned for the
caller to surface; a failing form aborts the load at that point.
Auto Trait Implementations§
impl Freeze for Session
impl !RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnsafeUnpin for Session
impl !UnwindSafe for Session
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more