Skip to main content

Session

Struct Session 

Source
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>

Source

pub fn new(vm: Vm<'p>, interner: &Interner) -> Self

Hold vm open for host calls. Nothing runs until Session::run_main.

Source

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.

Source

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).

Source

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.

Source

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.

Source

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.

Source

pub fn has(&self, name: &str) -> bool

Whether the program defines a function named name.

Source

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.

Source

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.

Source

pub fn lines(&self) -> &[String]

Every line the program has shown, main and every call since, in order.

Trait Implementations§

Source§

impl LoweredCalls for Session<'_>

Source§

fn take_unhandled(&mut self) -> Option<(String, Option<u32>)>

A failure the page’s own code contained while it ran — a turn a driving verb the program runs on its own page took (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.
Source§

fn call( &mut self, name: &str, args: Vec<RuntimeValue>, ) -> Result<RuntimeValue, String>

Source§

fn call_value( &mut self, callee: &RuntimeValue, args: Vec<RuntimeValue>, ) -> Result<RuntimeValue, String>

Source§

fn has(&self, name: &str) -> bool

Source§

fn reload(&mut self) -> Result<(), String>

The page reloaded: a fresh instance of the same program, its main run again.
Source§

fn lines(&self) -> &[String]

Every line the engine has shown, main and every call since, in order.
Source§

fn failure_site(&self) -> Option<u32>

The failure site (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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,