Skip to main content

PathAccessor

Trait PathAccessor 

Source
pub trait PathAccessor<F: EvalContextFamily>:
    Debug
    + Send
    + Sync {
    // Required methods
    fn get<'a>(&self, ctx: &F::Context<'a>, fields: &[Field]) -> Result<Value>;
    fn set<'a>(
        &self,
        ctx: &mut F::Context<'a>,
        fields: &[Field],
        value: &Value,
    ) -> Result<()>;
}
Expand description

Trait for accessing (reading and writing) path values in the context.

The evaluator calls get and set with a slice of Fields representing the structured path. Each field carries its own name and index keys; path interpretation is the integrator’s responsibility.

The fields slice is pre-allocated at parse time and passed by reference at execution time, so the hot path involves zero allocation and zero copy.

The type parameter F is the EvalContextFamily that determines the concrete context type. The lifetime on F::Context<'a> is introduced per method call, so PathAccessor<F> itself carries no lifetime and can be stored in Arc<dyn PathAccessor<F>>.

Required Methods§

Source

fn get<'a>(&self, ctx: &F::Context<'a>, fields: &[Field]) -> Result<Value>

Get the value at this path.

fields contains the structured path segments with per-field index keys. Path interpretation, including indexing (for example, ["key"], [0]), is not implemented by OTTL; the integrator must implement this method. For applying index keys to a value, use crate::helpers::apply_indexes.

Source

fn set<'a>( &self, ctx: &mut F::Context<'a>, fields: &[Field], value: &Value, ) -> Result<()>

Set the value at this path.

fields contains the structured path segments with per-field index keys. The integrator decides how to interpret the field chain and which keys to honour.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§