pub fn parse_expression(s: &str) -> Option<Expression>Expand description
Parse an expression string.
The string should be in the form ${...} containing a pipeline expression.
Returns None for anything else; parse_expression_detailed returns the
reason instead.
ยงExamples
use rite_model::expression::{parse_expression, Expression, Reference, RefType, PipeStage};
// Simple reference
let expr = parse_expression("${artifact.ksr}").unwrap();
assert!(matches!(expr, Expression::Reference(_)));
// Pipeline
let expr = parse_expression("${artifact.ksr | sha256 | hex}").unwrap();
if let Expression::Pipeline { stages, .. } = expr {
assert_eq!(stages.len(), 2);
assert_eq!(stages[0].function, "sha256");
assert_eq!(stages[1].function, "hex");
}