pub struct Context<'a> { /* private fields */ }Expand description
The runtime handle passed to Operation::execute.
A Context is a per-step view of the pipeline: it borrows the
operation’s OperationMetadata, the runtime Store, the
registered Extensions, and a scoped
prefix for looking up parameters. Operations use it to read
declared inputs, fetch extensions, emit errors, and record outputs.
Outputs are staged in two internal stores (operation-scoped and
global) and merged back into the runtime store after the step
finishes.
A Context validates every access against its metadata — calling
input, set_static_output,
set_derived_output, or
extension with a name the operation did not
declare returns an OperationError rather than silently
succeeding.
Implementations§
Source§impl Context<'_>
impl Context<'_>
Sourcepub fn new<'a>(
metadata: OperationMetadata,
param_prefix: &'a str,
store: &'a Store<StoreEntry>,
extensions: &'a Extensions,
) -> Context<'a>
pub fn new<'a>( metadata: OperationMetadata, param_prefix: &'a str, store: &'a Store<StoreEntry>, extensions: &'a Extensions, ) -> Context<'a>
Constructs a fresh Context with empty staged-output stores.
Called by the runtime immediately before a step executes; not
typically invoked from operation code.
Sourcepub fn input(&self, name: &str) -> Result<&StoreEntry, OperationError>
pub fn input(&self, name: &str) -> Result<&StoreEntry, OperationError>
Looks up a declared input by name, applying the step’s parameter
prefix automatically. Fails with
OperationError::UndeclaredInput if the name is not in the
operation’s metadata.
Sourcepub fn set_static_output(
&mut self,
name: &'static str,
entry: impl Into<StoreEntry>,
) -> Result<(), OperationError>
pub fn set_static_output( &mut self, name: &'static str, entry: impl Into<StoreEntry>, ) -> Result<(), OperationError>
Records a statically-named output declared on the operation’s
metadata as NameSpec::Static. Fails with
OperationError::UndeclaredOutput if no matching output is
declared.
Sourcepub fn set_derived_output(
&mut self,
input_name: &str,
entry: impl Into<StoreEntry>,
) -> Result<(), OperationError>
pub fn set_derived_output( &mut self, input_name: &str, entry: impl Into<StoreEntry>, ) -> Result<(), OperationError>
Records an output whose name is derived from a text input,
declared on the operation’s metadata as NameSpec::DerivedFrom
or NameSpec::DerivedWithDefault. Fails with
OperationError::UndeclaredDerivedOutput if no matching output
is declared.
Sourcepub fn extension<T: Extension>(
&self,
spec_name: &str,
) -> Result<&T, OperationError>
pub fn extension<T: Extension>( &self, spec_name: &str, ) -> Result<&T, OperationError>
Looks up a registered Extension of type T under a
declared extension spec. Fails with
OperationError::ExtensionNotFound if the spec is undeclared
or no extension was registered under the resolved name.
Sourcepub fn error(&self, message: impl Into<String>) -> OperationError
pub fn error(&self, message: impl Into<String>) -> OperationError
Builds an OperationError::Custom tagged with the operation’s
name for ad-hoc failure reporting. Prefer the
op_error! macro for format!-style
construction.