Skip to main content

PathTemplate

Struct PathTemplate 

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

Source

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.

Source

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.

Source

pub fn as_json(&self) -> &Value

The authored JSON, unchanged — for authoring checks and for handlers that re-serialize their own config.

Source

pub fn is_constant(&self) -> bool

Whether the destination folded to a compile-time constant, so Self::resolve returns the precomputed pair.

Source

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>

Source§

fn clone(&self) -> PathTemplate<R>

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<R: Debug + PathRoot> Debug for PathTemplate<R>

Source§

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

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

impl<R: PathRoot> Default for PathTemplate<R>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de, R: PathRoot> Deserialize<'de> for PathTemplate<R>

Source§

fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<R: PathRoot> From<&str> for PathTemplate<R>

Source§

fn from(path: &str) -> Self

Converts to this type from the input type.
Source§

impl<R: PathRoot> From<Value> for PathTemplate<R>

Source§

fn from(raw: Value) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<R> Freeze for PathTemplate<R>
where PhantomData<R>: Freeze,

§

impl<R> RefUnwindSafe for PathTemplate<R>

§

impl<R> Send for PathTemplate<R>
where PhantomData<R>: Send,

§

impl<R> Sync for PathTemplate<R>
where PhantomData<R>: Sync,

§

impl<R> Unpin for PathTemplate<R>
where PhantomData<R>: Unpin,

§

impl<R> UnsafeUnpin for PathTemplate<R>

§

impl<R> UnwindSafe for PathTemplate<R>

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
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.