pub struct Session<T: ModuleResolver = DefaultModuleResolver, IO: Io = SandboxedIo<NativeIo>> { /* private fields */ }Expand description
Evaluates queries one after another, carrying top-level let/var/def bindings and
import/include directives from each query to the next.
Errors show the query they happened in, named repl#N for the Nth query, so an error in a
function defined by an earlier query points at that query’s source.
let mut session = mq_lang::Session::new(mq_lang::DefaultEngine::default());
session.eval("let x = 41", mq_lang::null_input().into_iter()).unwrap();
let result = session.eval("x + 1", mq_lang::null_input().into_iter()).unwrap();
assert_eq!(result, vec![42.into()].into());Implementations§
Source§impl<T: ModuleResolver, IO: Io> Session<T, IO>
impl<T: ModuleResolver, IO: Io> Session<T, IO>
Sourcepub fn engine_mut(&mut self) -> &mut Engine<T, IO>
pub fn engine_mut(&mut self) -> &mut Engine<T, IO>
The engine queries run on, e.g. to define values or load modules.
Sourcepub fn into_engine(self) -> Engine<T, IO>
pub fn into_engine(self) -> Engine<T, IO>
Ends the session, returning its engine.
Trait Implementations§
Auto Trait Implementations§
impl<T = DefaultModuleResolver, IO = SandboxedIo> !RefUnwindSafe for Session<T, IO>
impl<T = DefaultModuleResolver, IO = SandboxedIo> !Send for Session<T, IO>
impl<T = DefaultModuleResolver, IO = SandboxedIo> !Sync for Session<T, IO>
impl<T = DefaultModuleResolver, IO = SandboxedIo> !UnwindSafe for Session<T, IO>
impl<T, IO> Forget for Session<T, IO>
impl<T, IO> Freeze for Session<T, IO>
impl<T, IO> Move for Session<T, IO>
impl<T, IO> Unpin for Session<T, IO>
impl<T, IO> UnsafeUnpin for Session<T, IO>where
Engine<T, IO>: UnsafeUnpin,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
Converts
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> ⓘ
Converts
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