engine.go (682B)
1 package engine 2 3 import ( 4 "context" 5 "io" 6 ) 7 8 // EngineIsh defines the interface for execution engines that handle vm initialization and execution, and rendering outputs. 9 type Engine interface { 10 // Init sets the engine up for vm execution. It must be called before Exec. 11 //Init(ctx context.Context) (bool, error) 12 // Exec executes the pending bytecode. 13 Exec(ctx context.Context, input []byte) (bool, error) 14 // Flush renders output according to the state of VM execution 15 // to the given io.Writer, and prepares the engine for another 16 // VM execution. 17 Flush(ctx context.Context, w io.Writer) (int, error) 18 // Finish must be called after the last call to Exec. 19 Finish() error 20 }