pub struct Session<'p> { /* private fields */ }Expand description
A VM whose program has run (or is about to), open to calls from the host.
Implementations§
Source§impl<'p> Session<'p>
impl<'p> Session<'p>
Sourcepub fn new(vm: Vm<'p>, interner: &Interner) -> Self
pub fn new(vm: Vm<'p>, interner: &Interner) -> Self
Hold vm open for host calls. Nothing runs until Session::run_main.
Sourcepub fn run_main(&mut self) -> Result<(), String>
pub fn run_main(&mut self) -> Result<(), String>
Run the program’s main code, once. A failure is reported and the session stays callable,
exactly as a browser can still call into a module whose main trapped.
Sourcepub fn take_unhandled(&mut self) -> Option<(String, Option<u32>)>
pub fn take_unhandled(&mut self) -> Option<(String, Option<u32>)>
The failure a page entry the program took itself contained and no handler absorbed, with
its failure site — the host carrying the page on takes it as the page’s failure
(Vm::take_unhandled).
Sourcepub fn invoke(
&mut self,
name: &str,
args: Vec<RuntimeValue>,
) -> Result<RuntimeValue, String>
pub fn invoke( &mut self, name: &str, args: Vec<RuntimeValue>, ) -> Result<RuntimeValue, String>
Call the function the program names name, with args in parameter order.
Sourcepub fn call_value(
&mut self,
callee: &RuntimeValue,
args: Vec<RuntimeValue>,
) -> Result<RuntimeValue, String>
pub fn call_value( &mut self, callee: &RuntimeValue, args: Vec<RuntimeValue>, ) -> Result<RuntimeValue, String>
Call a closure the program handed out — a completion, a listener, a route handler.
Sourcepub fn reload(&mut self) -> Result<(), String>
pub fn reload(&mut self) -> Result<(), String>
A page reload: the program re-instantiated with the same configuration and its main run again. Every global starts over; what lives outside the program (the document recorder, browser storage) is the host’s to keep or clear.
Sourcepub fn global_text(&self, name: &str) -> Option<String>
pub fn global_text(&self, name: &str) -> Option<String>
The current value of the named global, shown exactly as Show would render it — None
when the program declares no such global, or it has not been assigned one yet. The read a
host needs for state a lowering writes into a global specifically so the host can see it.
Sourcepub fn global_len(&self, name: &str) -> Option<usize>
pub fn global_len(&self, name: &str) -> Option<usize>
The number of top-level elements the named global holds, when it is a List/Set
([a, b, c]) or a Map ({k: v, k: v}) — None when the global does not exist, has no
value yet, or does not display as one of those two bracket shapes. Reads
Session::global_text’s display string rather than the VM’s own value representation
(nothing in this crate exposes that to a host), so it walks the string BRACKET-DEPTH-AWARE
— counting a comma only at depth 1, never inside a nested collection’s own brackets — the
one thing that would otherwise make this indistinguishable from a naive split. It remains
unsound only for a leaf value whose OWN display contains an unbracketed ,/[/{/}/]
(a Text, which displays raw and unquoted) — exactly why this is a length probe for a
table of plain scalars (an Int-keyed listener/site map, the shape a boundedness proof
measures), not a general-purpose value parser.
Trait Implementations§
Source§impl LoweredCalls for Session<'_>
impl LoweredCalls for Session<'_>
Source§fn take_unhandled(&mut self) -> Option<(String, Option<u32>)>
fn take_unhandled(&mut self) -> Option<(String, Option<u32>)>
crate::semantics::builtins::BuiltinId::DomDispatchEntry),
whose failure door already heard it and no handler absorbed — with its failure site, for
the host to hold as the page’s failure. None for an engine whose entries report through
this host alone.fn call( &mut self, name: &str, args: Vec<RuntimeValue>, ) -> Result<RuntimeValue, String>
fn call_value( &mut self, callee: &RuntimeValue, args: Vec<RuntimeValue>, ) -> Result<RuntimeValue, String>
fn has(&self, name: &str) -> bool
Source§fn reload(&mut self) -> Result<(), String>
fn reload(&mut self) -> Result<(), String>
Source§fn lines(&self) -> &[String]
fn lines(&self) -> &[String]
Source§fn failure_site(&self) -> Option<u32>
fn failure_site(&self) -> Option<u32>
Stmt::Site) in force when the most recent failed call trapped — where
in the page’s source it failed — for an engine that tracks one.Auto Trait Implementations§
impl<'p> Freeze for Session<'p>
impl<'p> !RefUnwindSafe for Session<'p>
impl<'p> !Send for Session<'p>
impl<'p> !Sync for Session<'p>
impl<'p> Unpin for Session<'p>
impl<'p> UnsafeUnpin for Session<'p>
impl<'p> !UnwindSafe for Session<'p>
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.