pub trait ProgramVm {
    // Required methods
    fn env(&self) -> &EnvDb;
    fn env_mut(&mut self) -> &mut EnvDb;
    fn ctx(&self) -> &dyn ProgramVm;
    fn auth(&self) -> &AuthCtx;
    fn eval_query(&mut self, query: CrudCode) -> Result<Code, ErrorVm>;
    fn as_program_ref(&self) -> ProgramRef<'_>;

    // Provided methods
    fn load_ops(env: &mut EnvDb)
       where Self: Sized { ... }
    fn add_lambda(&mut self, f: FunDef, body: Code) { ... }
    fn update_lambda(&mut self, f: FunDef, body: Code) { ... }
    fn add_ident(&mut self, name: &str, v: Code) { ... }
    fn find_ident(&self, key: &str) -> Option<&Code> { ... }
}
Expand description

A trait to allow split the execution of programs to allow executing queries that take in account each program state/enviroment.

In concrete, it allows to run queries that run on the SpaceTimeDb engine.

It could also permite run queries backed by different engines, like in MySql.

Required Methods§

source

fn env(&self) -> &EnvDb

source

fn env_mut(&mut self) -> &mut EnvDb

source

fn ctx(&self) -> &dyn ProgramVm

source

fn auth(&self) -> &AuthCtx

source

fn eval_query(&mut self, query: CrudCode) -> Result<Code, ErrorVm>

Allows to execute the query with the state carried by the implementation of this trait

source

fn as_program_ref(&self) -> ProgramRef<'_>

Provided Methods§

source

fn load_ops(env: &mut EnvDb)where Self: Sized,

Load the in-built functions that define the operators of the VM, like +, and, ==, etc.

source

fn add_lambda(&mut self, f: FunDef, body: Code)

Add a function that is defined natively by Code

source

fn update_lambda(&mut self, f: FunDef, body: Code)

source

fn add_ident(&mut self, name: &str, v: Code)

Add a ident into the environment, similar to let x = expr

source

fn find_ident(&self, key: &str) -> Option<&Code>

Locates the ident in the environment

Implementors§