Skip to main content

StepAccumulator

Trait StepAccumulator 

Source
pub trait StepAccumulator: Sized {
Show 14 methods // Required method fn steps_mut(&mut self) -> &mut Vec<BuilderStep>; // Provided methods fn to(self, endpoint: impl Into<String>) -> Self { ... } fn process<F, Fut>(self, f: F) -> Self where F: Fn(Exchange) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<Exchange, CamelError>> + Send + 'static { ... } fn process_fn(self, processor: BoxProcessor) -> Self { ... } fn set_header(self, key: impl Into<String>, value: impl Into<Value>) -> Self { ... } fn map_body<F>(self, mapper: F) -> Self where F: Fn(Body) -> Body + Clone + Send + Sync + 'static { ... } fn set_body<B>(self, body: B) -> Self where B: Into<Body> + Clone + Send + Sync + 'static { ... } fn set_body_fn<F>(self, expr: F) -> Self where F: Fn(&Exchange) -> Body + Clone + Send + Sync + 'static { ... } fn set_header_fn<F>(self, key: impl Into<String>, expr: F) -> Self where F: Fn(&Exchange) -> Value + Clone + Send + Sync + 'static { ... } fn aggregate(self, config: AggregatorConfig) -> Self { ... } fn stop(self) -> Self { ... } fn log(self, message: impl Into<String>, level: LogLevel) -> Self { ... } fn convert_body_to(self, target: BodyType) -> Self { ... } fn script( self, language: impl Into<String>, script: impl Into<String>, ) -> Self { ... }
}
Expand description

Shared step-accumulation methods for all builder types.

Implementors provide steps_mut() and get step-adding methods for free. filter() and other branching methods are NOT included — they return different types per builder and stay as per-builder methods.

Required Methods§

Source

fn steps_mut(&mut self) -> &mut Vec<BuilderStep>

Provided Methods§

Source

fn to(self, endpoint: impl Into<String>) -> Self

Source

fn process<F, Fut>(self, f: F) -> Self
where F: Fn(Exchange) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<Exchange, CamelError>> + Send + 'static,

Source

fn process_fn(self, processor: BoxProcessor) -> Self

Source

fn set_header(self, key: impl Into<String>, value: impl Into<Value>) -> Self

Source

fn map_body<F>(self, mapper: F) -> Self
where F: Fn(Body) -> Body + Clone + Send + Sync + 'static,

Source

fn set_body<B>(self, body: B) -> Self
where B: Into<Body> + Clone + Send + Sync + 'static,

Source

fn set_body_fn<F>(self, expr: F) -> Self
where F: Fn(&Exchange) -> Body + Clone + Send + Sync + 'static,

Source

fn set_header_fn<F>(self, key: impl Into<String>, expr: F) -> Self
where F: Fn(&Exchange) -> Value + Clone + Send + Sync + 'static,

Source

fn aggregate(self, config: AggregatorConfig) -> Self

Source

fn stop(self) -> Self

Stop processing this exchange immediately. No further steps in the current pipeline will run.

Can be used at any point in the route: directly on RouteBuilder, inside .filter(), inside .split(), etc.

Source

fn log(self, message: impl Into<String>, level: LogLevel) -> Self

Log a message at the specified level.

The message will be logged when an exchange passes through this step.

Source

fn convert_body_to(self, target: BodyType) -> Self

Convert the message body to the target type.

Supported: Text ↔ Json ↔ Bytes. Body::Stream always fails. Returns TypeConversionFailed if conversion is not possible.

§Example
route.set_body(Value::String(r#"{"x":1}"#.into()))
     .convert_body_to(BodyType::Json)
     .to("direct:next")
Source

fn script(self, language: impl Into<String>, script: impl Into<String>) -> Self

Execute a script that can modify the exchange (headers, properties, body).

The script has access to headers, properties, and body variables and can modify them with assignment syntax: headers["k"] = v.

§Example
// ignore: requires full CamelContext setup with registered language
route.script("rhai", r#"headers["tenant"] = "acme"; body = body + "_processed""#)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§