Skip to main content

SequenceContext

Struct SequenceContext 

Source
pub struct SequenceContext { /* private fields */ }
Expand description

A point in a running sequence, and everything reachable from it (SequenceContext).

This is what an expression calls ThisContext, obtained from Thread::get_sequence_context. It is the door to the variable scopes, Locals, Parameters, FileGlobals, StationGlobals, and to RunState.

§Lifetimes: what may outlive the run, and what may not

A host holding the wrong reference after an execution ends keeps a COM object alive on a finished run. The documentation draws the line explicitly: these exist before, and persist after, the execution, ///

, while everything else belongs to the run, file_globals most notably: it is the execution’s own copy, and writing to it does not touch the file’s stored defaults.

So the safe pattern for a host is to read what it needs from a context while the run is alive and keep the data, not the reference. Values that must outlive the run come from the engine or the file instead: Engine::globals for station globals with no execution at all, and SequenceFile::file_globals_default_values for the file’s edit-time defaults.

Implementations§

Source§

impl SequenceContext

Source

pub fn as_property_object(&self) -> Result<PropertyObject, Error>

The context as a property tree (SequenceContext.AsPropertyObject).

§Errors

Error if the COM call fails or returns an unexpected type.

Source

pub fn locals(&self) -> Result<PropertyObject, Error>

The running sequence’s local variables (SequenceContext.Locals).

The run’s own copy, it does not outlive the execution.

§Errors

Error if the COM call fails or returns an unexpected type.

Source

pub fn parameters(&self) -> Result<PropertyObject, Error>

The running sequence’s parameters (SequenceContext.Parameters).

§Errors

Error if the COM call fails or returns an unexpected type.

Source

pub fn file_globals(&self) -> Result<PropertyObject, Error>

The executing file’s globals (SequenceContext.FileGlobals).

Belongs to the run. This is the execution’s own copy: changes here do not affect the defaults stored in the sequence file, and the object is meaningless once the run is over. Read what is needed now, or use SequenceFile::file_globals_default_values for the values that live in the file.

§Errors

Error if the COM call fails or returns an unexpected type.

Source

pub fn station_globals(&self) -> Result<PropertyObject, Error>

The station’s global variables (SequenceContext.StationGlobals).

Outlives the run, and is shared: a change made here is seen by every execution in the session, and persists on disk. Reachable without any execution through Engine::globals, which is the better route when no run is involved.

§Errors

Error if the COM call fails or returns an unexpected type.

Source

pub fn execution(&self) -> Result<Execution, Error>

The execution this context belongs to (SequenceContext.Execution).

§Errors

Error if the COM call fails or returns an unexpected type.

Source

pub fn thread(&self) -> Result<Thread, Error>

The thread this context belongs to (SequenceContext.Thread).

§Errors

Error if the COM call fails or returns an unexpected type.

Source

pub fn sequence_file(&self) -> Result<SequenceFile, Error>

The file the running sequence came from (SequenceContext.SequenceFile).

Outlives the run, it is the loaded file, not a copy.

§Errors

Error if the COM call fails or returns an unexpected type.

Source

pub fn sequence(&self) -> Result<Sequence, Error>

The sequence being run (SequenceContext.Sequence).

§Errors

Error if the COM call fails or returns an unexpected type.

Source

pub fn call_stack_depth(&self) -> Result<i32, Error>

How deep this frame sits in the call stack (SequenceContext.CallStackDepth).

§Errors

Error if the COM call fails or returns an unexpected type.

Source

pub fn step_index(&self) -> Result<i32, Error>

The index of the step being run (SequenceContext.StepIndex).

§Errors

Error if the COM call fails or returns an unexpected type.

Source

pub fn num_steps_executed(&self) -> Result<i32, Error>

How many steps have run so far (SequenceContext.NumStepsExecuted).

§Errors

Error if the COM call fails or returns an unexpected type.

Source

pub fn sequence_failed(&self) -> Result<bool, Error>

Whether the sequence has failed (SequenceContext.SequenceFailed).

§Errors

Error if the COM call fails or returns an unexpected type.

Source

pub fn error_reported(&self) -> Result<bool, Error>

Whether a run-time error has been reported (SequenceContext.ErrorReported).

§Errors

Error if the COM call fails or returns an unexpected type.

Source

pub fn run_time_error_message(&self) -> Result<String, Error>

The current run-time error message (SequenceContext.RunTimeErrorMessage).

§Errors

Error if the COM call fails or returns an unexpected type.

Source

pub fn step(&self) -> Result<Step, Error>

The step being run right now (SequenceContext.Step).

Fallible by nature. The engine documents this property as existing only while a step executes, between steps, and at a breakpoint, there is no current step. An error here is a legitimate state, not a defect, which is why it is not reported as an empty value.

§Errors

Error if no step is executing, or the COM call fails.

Trait Implementations§

Source§

impl Debug for SequenceContext

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.