Skip to main content

camel_bean/
processor.rs

1use async_trait::async_trait;
2use camel_api::{CamelError, Exchange};
3
4#[async_trait]
5pub trait BeanProcessor: Send + Sync {
6    /// Invoke a named method on this bean, mutating the exchange in place.
7    ///
8    /// The `method` parameter selects the target method by name. When a bean
9    /// exposes multiple methods with the same name (overloads), callers may
10    /// supply [`method_params`](BeanProcessor::method_params) to disambiguate.
11    async fn call(&self, method: &str, exchange: &mut Exchange) -> Result<(), CamelError>;
12
13    /// Returns the list of method names this bean exposes.
14    fn methods(&self) -> Vec<String>;
15
16    /// Optional parameter-type hints for overload resolution.
17    ///
18    /// When `Some`, the vector contains fully-qualified type names (e.g.
19    /// `"String"`, `"i32"`) that identify which overload of a method to invoke.
20    ///
21    /// TODO: Full overload resolution (matching by parameter types at runtime)
22    /// is not yet implemented. Currently only method-name dispatch is supported.
23    fn method_params(&self) -> Option<Vec<String>> {
24        None
25    }
26
27    async fn on_start(&self) -> Result<(), CamelError> {
28        Ok(())
29    }
30
31    async fn on_stop(&self) -> Result<(), CamelError> {
32        Ok(())
33    }
34}