Skip to main content

Context

Struct Context 

Source
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<'_>

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Auto Trait Implementations§

§

impl<'a> Freeze for Context<'a>

§

impl<'a> !RefUnwindSafe for Context<'a>

§

impl<'a> Send for Context<'a>

§

impl<'a> Sync for Context<'a>

§

impl<'a> Unpin for Context<'a>

§

impl<'a> UnsafeUnpin for Context<'a>

§

impl<'a> !UnwindSafe for Context<'a>

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.