pub trait OttlParser<F: EvalContextFamily> {
// Required methods
fn is_error(&self) -> Result<()>;
fn execute<'a>(&self, ctx: &mut F::Context<'a>) -> Result<Value>;
}Expand description
Public API trait for the OTTL Parser.
This trait defines the interface for executing parsed OTTL statements.
The type parameter F is the EvalContextFamily that determines the
concrete evaluation context type.
§Example
ⓘ
use ottl::{OttlParser, Parser, EvalContextFamily};
let parser = Parser::<MyFamily>::new(...);
// Check for parsing errors
parser.is_error()?;
// Execute the statement
let mut ctx = MyContext { /* ... */ };
let result = parser.execute(&mut ctx)?;Required Methods§
Sourcefn is_error(&self) -> Result<()>
fn is_error(&self) -> Result<()>
Checks if the parser encountered any errors during creation.
Call this method after creating a parser to verify that the OTTL expression was parsed successfully.
§Returns
Ok(())- if no errors occurred during parsingErr(BoxError)- if parsing failed with error details
Sourcefn execute<'a>(&self, ctx: &mut F::Context<'a>) -> Result<Value>
fn execute<'a>(&self, ctx: &mut F::Context<'a>) -> Result<Value>
Executes this OTTL statement with the given context.
This method evaluates the parsed OTTL expression, invoking any bound editor or converter callbacks as needed and resolving path references.
§Arguments
ctx- The mutable evaluation context that provides access to telemetry data and can be modified by editor functions.
§Returns
Ok(Value)- The result of evaluating the expression. If expression has no return value, returnsValue::Nil.Err(BoxError)- An error if evaluation fails (e.g., type mismatch, missing path, callback error).
Implementors§
impl<F: EvalContextFamily> OttlParser<F> for Parser<F>
Implementation of the OttlParser trait for Parser.