pub struct ExecutorContext {
pub engine: Arc<Box<dyn EngineManager>>,
pub fs: Arc<FileManager>,
pub settings: ExecutorSettings,
pub context_type: ContextType,
}Expand description
The executor context.
Cloning will return another handle to the same engine connection/session,
as this uses Arc under the hood.
Fields§
§engine: Arc<Box<dyn EngineManager>>§fs: Arc<FileManager>§settings: ExecutorSettings§context_type: ContextTypeImplementations§
Source§impl ExecutorContext
impl ExecutorContext
pub async fn open_module( &self, path: &ImportPath, attrs: &[Node<Annotation>], resolved_path: &ModulePath, exec_state: &mut ExecState, source_range: SourceRange, ) -> Result<ModuleId, KclError>
pub async fn exec_module_from_ast( &self, program: &Node<Program>, module_id: ModuleId, path: &ModulePath, exec_state: &mut ExecState, source_range: SourceRange, preserve_mem: bool, ) -> Result<ModuleExecutionOutcome, KclError>
Source§impl ExecutorContext
impl ExecutorContext
Sourcepub async fn new(client: &Client, settings: ExecutorSettings) -> Result<Self>
pub async fn new(client: &Client, settings: ExecutorSettings) -> Result<Self>
Create a new default executor context.
pub async fn new_mock(settings: Option<ExecutorSettings>) -> Self
pub fn new_forwarded_mock(engine: Arc<Box<dyn EngineManager>>) -> Self
Sourcepub async fn new_with_client(
settings: ExecutorSettings,
token: Option<String>,
engine_addr: Option<String>,
) -> Result<Self>
pub async fn new_with_client( settings: ExecutorSettings, token: Option<String>, engine_addr: Option<String>, ) -> Result<Self>
Create a new default executor context.
With a kittycad client.
This allows for passing in ZOO_API_TOKEN and ZOO_HOST as environment
variables.
But also allows for passing in a token and engine address directly.
Sourcepub async fn new_with_default_client() -> Result<Self>
pub async fn new_with_default_client() -> Result<Self>
Create a new default executor context.
With the default kittycad client.
This allows for passing in ZOO_API_TOKEN and ZOO_HOST as environment
variables.
Sourcepub async fn new_for_unit_test(engine_addr: Option<String>) -> Result<Self>
pub async fn new_for_unit_test(engine_addr: Option<String>) -> Result<Self>
For executing unit tests.
pub fn is_mock(&self) -> bool
Sourcepub async fn no_engine_commands(&self) -> bool
pub async fn no_engine_commands(&self) -> bool
Returns true if we should not send engine commands for any reason.
pub async fn send_clear_scene( &self, exec_state: &mut ExecState, source_range: SourceRange, ) -> Result<(), KclError>
pub async fn bust_cache_and_reset_scene( &self, ) -> Result<ExecOutcome, KclErrorWithOutputs>
pub async fn run_mock( &self, program: &Program, mock_config: &MockConfig, ) -> Result<ExecOutcome, KclErrorWithOutputs>
pub async fn run_with_caching( &self, program: Program, ) -> Result<ExecOutcome, KclErrorWithOutputs>
Sourcepub async fn run(
&self,
program: &Program,
exec_state: &mut ExecState,
) -> Result<(EnvironmentRef, Option<ModelingSessionData>), KclErrorWithOutputs>
pub async fn run( &self, program: &Program, exec_state: &mut ExecState, ) -> Result<(EnvironmentRef, Option<ModelingSessionData>), KclErrorWithOutputs>
Perform the execution of a program.
To access non-fatal errors and warnings, extract them from the ExecState.
Sourcepub async fn run_concurrent(
&self,
program: &Program,
exec_state: &mut ExecState,
universe_info: Option<(HashMap<String, (Node<ImportStatement>, ModuleId, ModulePath, ModuleRepr)>, HashMap<TypedPath, Node<ImportStatement>>)>,
preserve_mem: bool,
) -> Result<(EnvironmentRef, Option<ModelingSessionData>), KclErrorWithOutputs>
pub async fn run_concurrent( &self, program: &Program, exec_state: &mut ExecState, universe_info: Option<(HashMap<String, (Node<ImportStatement>, ModuleId, ModulePath, ModuleRepr)>, HashMap<TypedPath, Node<ImportStatement>>)>, preserve_mem: bool, ) -> Result<(EnvironmentRef, Option<ModelingSessionData>), KclErrorWithOutputs>
Perform the execution of a program using a concurrent execution model.
To access non-fatal errors and warnings, extract them from the ExecState.
Sourcepub async fn prepare_snapshot(&self) -> Result<TakeSnapshot, ExecError>
pub async fn prepare_snapshot(&self) -> Result<TakeSnapshot, ExecError>
Get a snapshot of the current scene.
Sourcepub async fn export(
&self,
format: OutputFormat3d,
) -> Result<Vec<RawFile>, KclError>
pub async fn export( &self, format: OutputFormat3d, ) -> Result<Vec<RawFile>, KclError>
Export the current scene as a CAD file.
Sourcepub async fn export_step(
&self,
deterministic_time: bool,
) -> Result<Vec<RawFile>, KclError>
pub async fn export_step( &self, deterministic_time: bool, ) -> Result<Vec<RawFile>, KclError>
Export the current scene as a STEP file.
pub async fn close(&self)
Trait Implementations§
Source§impl Clone for ExecutorContext
impl Clone for ExecutorContext
Source§fn clone(&self) -> ExecutorContext
fn clone(&self) -> ExecutorContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ExecutorContext
impl !RefUnwindSafe for ExecutorContext
impl Send for ExecutorContext
impl Sync for ExecutorContext
impl Unpin for ExecutorContext
impl !UnwindSafe for ExecutorContext
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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 moreSource§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
type Err = Infallible
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.