spacetimedb_vm/
program.rs

1//! Definition for a `Program` to run code.
2//!
3//! It carries an [EnvDb] with the functions, idents, types.
4
5use crate::errors::ErrorVm;
6use crate::expr::{Code, CrudExpr, SourceSet};
7use spacetimedb_sats::ProductValue;
8
9/// A trait to allow split the execution of `programs` to allow executing
10/// `queries` that take in account each `program` state/enviroment.
11///
12/// To be specific, it allows you to run queries that run on the `SpacetimeDB` engine.
13///
14/// It could also permit run queries backed by different engines, like in `MySql`.
15pub trait ProgramVm {
16    /// Allows to execute the query with the state carried by the implementation of this
17    /// trait
18    fn eval_query<const N: usize>(&mut self, query: CrudExpr, sources: Sources<'_, N>) -> Result<Code, ErrorVm>;
19}
20
21pub type Sources<'a, const N: usize> = &'a mut SourceSet<Vec<ProductValue>, N>;