@@ -275,14 +275,37 @@ pub enum TxnCleanup {
275275
276276#[ derive( Debug , Clone , Copy , PartialEq ) ]
277277pub enum ProgramExecutionState {
278+ /// No steps of the program was executed
278279 Init ,
279- Run ,
280+ /// Program started execution but didn't reach any terminal state
281+ Running ,
282+ /// Interrupt requested for the program
280283 Interrupting ,
284+ /// Terminal state: program interrupted
281285 Interrupted ,
286+ /// Terminal state: program finished successfully
282287 Done ,
288+ /// Terminal state: program failed with error
283289 Failed ,
284290}
285291
292+ impl ProgramExecutionState {
293+ pub fn is_running ( & self ) -> bool {
294+ matches ! (
295+ self ,
296+ ProgramExecutionState :: Interrupting | ProgramExecutionState :: Running
297+ )
298+ }
299+ pub fn is_terminal ( & self ) -> bool {
300+ matches ! (
301+ self ,
302+ ProgramExecutionState :: Interrupted
303+ | ProgramExecutionState :: Failed
304+ | ProgramExecutionState :: Done
305+ )
306+ }
307+ }
308+
286309/// The program state describes the environment in which the program executes.
287310pub struct ProgramState {
288311 pub io_completions : Option < IOCompletions > ,
@@ -656,7 +679,7 @@ impl Program {
656679 query_mode : QueryMode ,
657680 waker : Option < & Waker > ,
658681 ) -> Result < StepResult > {
659- state. execution_state = ProgramExecutionState :: Run ;
682+ state. execution_state = ProgramExecutionState :: Running ;
660683 let result = match query_mode {
661684 QueryMode :: Normal => self . normal_step ( state, mv_store, pager, waker) ,
662685 QueryMode :: Explain => self . explain_step ( state, mv_store, pager) ,
0 commit comments