Skip to main content

ExecutionScope

Struct ExecutionScope 

Source
pub struct ExecutionScope {
    pub outputs: HashMap<String, Value>,
    pub vars: HashMap<String, Value>,
    pub trigger: Value,
    pub state: RunState,
    pub bits: HashMap<String, (bool, bool)>,
    pub locals: HashMap<String, Value>,
    pub local_bits: (bool, bool),
    pub drone_id: String,
    pub never_ask: bool,
}
Expand description

Holds the per-run scope. Maps:

  • outputs[block_id] — the JSON output of a completed block
  • vars[name] — drone-scope variables (set by Variables block)
  • trigger — what started the run: the input of rundrone, or what the job passed; Null when nothing did ({{trigger.*}})
  • drone_id — the drone the run belongs to, for what a block keeps across runs and must not share with another drone (the Task block’s dedupe key); empty for a scope built outside a run

Fields§

§outputs: HashMap<String, Value>§vars: HashMap<String, Value>

What {{var.name}} reads: a mirror of state’s values.

§trigger: Value§state: RunState

The run’s named values with their reducers and taint bits. Write through write_var, which keeps vars in step.

§bits: HashMap<String, (bool, bool)>

Each block’s output bits (tainted, derived), set by the scheduler and by the blocks that compute one. A block with none is clean.

§locals: HashMap<String, Value>

{{item}} and {{index}} while a for-each runs its body, and the bits of the item.

§local_bits: (bool, bool)§drone_id: String§never_ask: bool

A background poll’s call: with a Vault credential it may use only what the person already granted (“Always”), and never asks (server::drone_vault::Asking::Never).

Implementations§

Source§

impl ExecutionScope

Source

pub fn new() -> Self

Source

pub fn with_trigger(trigger: Value) -> Self

A scope for a run started by trigger.

Source

pub fn value_of(&self, template: &str) -> Value

The value a template stands for: the raw value (a list, an object, a number) when the template is one {{...}} token, else the text with every token filled in.

Source

pub fn lookup_ref(&self, path: &str) -> Option<Value>

What one {{path}} token names, as the value itself, or none when nothing is there. value_of answers a missing token with its own text; this tells the two apart.

Source

pub fn declare_var( &mut self, name: &str, reducer: Reducer, ) -> Result<(), String>

Declare how writes to name combine (replace when never declared).

Source

pub fn write_var(&mut self, name: &str, value: Tv) -> Result<(), String>

Write a variable under its reducer, keeping the value {{var.name}} reads in step with the state. An error leaves both as they were.

Source

pub fn bits_of(&self, template: &str) -> (bool, bool)

The bits (tainted, derived) of a text made by filling in template: tainted when any value it reads is, derived when none is tainted and one is derived. The trigger is outside text when something started the run.

Source

pub fn for_drone(drone_id: &str, trigger: Value) -> Self

A scope for a run of the drone drone_id, started by trigger.

Source

pub fn resolve(&self, input: &str) -> String

Resolve {{...}} tokens in input against this scope. Unknown tokens are left as-is (Phase 1 — Phase 2 will surface them as validation errors).

Source

pub fn resolve_with( &self, input: &str, wrap: impl Fn(String) -> String, ) -> String

Like resolve, but each resolved value goes through wrap before it is written, so a node can quote what came from outside (an event, an API body, an agent’s reply) while its own text stays as the graph wrote it. An unresolved token is left as-is and not wrapped.

Source

fn lookup(&self, token: &str) -> Option<Value>

What a token stands for: the reference, then each | filter after it.

Source

fn lookup_path(&self, path: &str) -> Option<Value>

Trait Implementations§

Source§

impl Clone for ExecutionScope

Source§

fn clone(&self) -> ExecutionScope

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ExecutionScope

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for ExecutionScope

Source§

fn default() -> ExecutionScope

Returns the “default value” for a type. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> NoneValue for T
where T: Default,

§

type NoneType = T

§

fn null_value() -> T

The none-equivalent value.
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more