pub struct LanguageExpressionEval { /* private fields */ }Expand description
An Expression bound to trusted route metadata, evaluating to
Result<Value, CamelError>.
Implementations§
Source§impl LanguageExpressionEval
impl LanguageExpressionEval
Sourcepub fn new(expr: Arc<dyn Expression>, meta: EvalMeta) -> Self
pub fn new(expr: Arc<dyn Expression>, meta: EvalMeta) -> Self
Bind an expression to route metadata.
Sourcepub async fn evaluate(&self, exchange: &Exchange) -> Result<Value, CamelError>
pub async fn evaluate(&self, exchange: &Exchange) -> Result<Value, CamelError>
Evaluate the bound expression, mapping failures to
CamelError::ExpressionFailed via to_expression_failed.
Sourcepub fn into_value_fn(
self,
) -> Arc<dyn Fn(&Exchange) -> BoxValueFuture + Send + Sync> ⓘ
pub fn into_value_fn( self, ) -> Arc<dyn Fn(&Exchange) -> BoxValueFuture + Send + Sync> ⓘ
Convert into a clone-based async closure matching the async arm of
camel_api::ValueSource. The closure clones the expression handle, the
metadata and the exchange per call (the boxed future is 'static).
The Exchange clone is the real per-call cost: a deep copy
proportional to payload size for Json/Text/Xml bodies and
header/property maps, while Bytes is refcount-cheap and Stream
shares its single-consumption handle, so read-only isolation for
streams rests on the stream-read guard, not the clone. If profiling
ever flags this, the upgrade path is a lifetime-carrying
BoxValueFuture<'a> or an owned-Exchange API.