pub struct Context<'rt> { /* private fields */ }Expand description
An execution context: a global object plus the builtins installed on it.
Mirrors the role of JSContext in the QuickJS C API.
Implementations§
Source§impl<'rt> Context<'rt>
impl<'rt> Context<'rt>
Sourcepub fn set_script_name(&mut self, name: impl Into<String>)
pub fn set_script_name(&mut self, name: impl Into<String>)
Name the scripts this context evaluates, for stack traces.
Mirrors what qjs passes to JS_Eval: -e code is <cmdline>, a script file
is its own path. Without a name, frames print <input>, which is what the
reference uses for code with no file behind it.
Sourcepub fn eval(&mut self, source: &str) -> Result<Value>
pub fn eval(&mut self, source: &str) -> Result<Value>
Evaluate source as a global script and return its completion value.
The value is reported the way qjs -e reports it: a string for anything the
script leaves on the stack, and nothing at all for undefined.
Sourcepub fn last_value(&self) -> &Value
pub fn last_value(&self) -> &Value
The value of the script that ran last.
Auto Trait Implementations§
impl<'rt> !RefUnwindSafe for Context<'rt>
impl<'rt> !Send for Context<'rt>
impl<'rt> !Sync for Context<'rt>
impl<'rt> !UnwindSafe for Context<'rt>
impl<'rt> Forget for Context<'rt>
impl<'rt> Freeze for Context<'rt>
impl<'rt> Move for Context<'rt>
impl<'rt> Unpin for Context<'rt>
impl<'rt> UnsafeUnpin for Context<'rt>
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
Mutably borrows from an owned value. Read more