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 blockvars[name]— drone-scope variables (set by Variables block)trigger— what started the run: the input ofrundrone, or what the job passed;Nullwhen 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: RunStateThe 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: boolA 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
impl ExecutionScope
pub fn new() -> Self
Sourcepub fn with_trigger(trigger: Value) -> Self
pub fn with_trigger(trigger: Value) -> Self
A scope for a run started by trigger.
Sourcepub fn value_of(&self, template: &str) -> Value
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.
Sourcepub fn lookup_ref(&self, path: &str) -> Option<Value>
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.
Sourcepub fn declare_var(
&mut self,
name: &str,
reducer: Reducer,
) -> Result<(), String>
pub fn declare_var( &mut self, name: &str, reducer: Reducer, ) -> Result<(), String>
Declare how writes to name combine (replace when never declared).
Sourcepub fn write_var(&mut self, name: &str, value: Tv) -> Result<(), String>
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.
Sourcepub fn bits_of(&self, template: &str) -> (bool, bool)
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.
Sourcepub fn for_drone(drone_id: &str, trigger: Value) -> Self
pub fn for_drone(drone_id: &str, trigger: Value) -> Self
A scope for a run of the drone drone_id, started by trigger.
Sourcepub fn resolve(&self, input: &str) -> String
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).
Sourcepub fn resolve_with(
&self,
input: &str,
wrap: impl Fn(String) -> String,
) -> String
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.
Sourcefn lookup(&self, token: &str) -> Option<Value>
fn lookup(&self, token: &str) -> Option<Value>
What a token stands for: the reference, then each | filter after it.
fn lookup_path(&self, path: &str) -> Option<Value>
Trait Implementations§
Source§impl Clone for ExecutionScope
impl Clone for ExecutionScope
Source§fn clone(&self) -> ExecutionScope
fn clone(&self) -> ExecutionScope
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ExecutionScope
impl Debug for ExecutionScope
Source§impl Default for ExecutionScope
impl Default for ExecutionScope
Source§fn default() -> ExecutionScope
fn default() -> ExecutionScope
Auto Trait Implementations§
impl Freeze for ExecutionScope
impl RefUnwindSafe for ExecutionScope
impl Send for ExecutionScope
impl Sync for ExecutionScope
impl Unpin for ExecutionScope
impl UnsafeUnpin for ExecutionScope
impl UnwindSafe for ExecutionScope
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSync for T
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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