pub struct PathTemplate<R: PathRoot = ContextRoot> { /* private fields */ }Expand description
A config field naming a write destination, expressed as JSONLogic.
R fixes the rooting: ContextRoot for a path that names its own root,
DataRoot for one relative to data.
The static spelling is a JSON string and keeps its precomputed fast path:
{ "path": "data.total" }A dynamic destination is any expression resolving to a path string:
{ "path": {"cat": ["data.accounts.", {"var": "data.account_id"}, ".balance"]} }The expression resolves to the name of a location, never to the value at one. It is evaluated against the message context like any other parameter.
Implementations§
Source§impl<R: PathRoot> PathTemplate<R>
impl<R: PathRoot> PathTemplate<R>
Sourcepub fn compile(&mut self, c: &TemplateCompiler, label: &str) -> Result<()>
pub fn compile(&mut self, c: &TemplateCompiler, label: &str) -> Result<()>
Compile the expression and, when it folded to a constant, precompute its
(dotted, parts) pair. Called once at engine construction by
LogicCompiler.
§Errors
As Template::compile, plus a resolution failure if the constant does
not coerce to a path string.
Sourcepub fn resolve(&self, ctx: &TaskContext<'_>) -> Result<ResolvedPath>
pub fn resolve(&self, ctx: &TaskContext<'_>) -> Result<ResolvedPath>
The destination for this message as (dotted path, split parts).
Constant destinations return the precomputed pair — two Arc clones,
no splitting, no allocation. Dynamic ones resolve to a plain string and
split it.
§Errors
crate::DataflowError::LogicEvaluation if the expression fails to
evaluate, or if it was never compiled and is not a literal string.
Sourcepub fn as_json(&self) -> &Value
pub fn as_json(&self) -> &Value
The authored JSON, unchanged — for authoring checks and for handlers that re-serialize their own config.
Sourcepub fn is_constant(&self) -> bool
pub fn is_constant(&self) -> bool
Whether the destination folded to a compile-time constant, so
Self::resolve returns the precomputed pair.
Sourcepub fn constant_path(&self) -> Option<&str>
pub fn constant_path(&self) -> Option<&str>
The constant destination as a dotted string, when it folded to one.
For diagnostics that want to name the destination without a message in
hand — error labels, the workflow visualizer, authoring issues. None
for a dynamic destination, which has no single answer.
Trait Implementations§
Source§impl<R: Clone + PathRoot> Clone for PathTemplate<R>
impl<R: Clone + PathRoot> Clone for PathTemplate<R>
Source§fn clone(&self) -> PathTemplate<R>
fn clone(&self) -> PathTemplate<R>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more