Skip to main content

camel_component_api/
lib.rs

1//! camel-component-api — traits and types for building Camel components.
2//!
3//! Provides the core abstractions (`Component`, `Endpoint`, `Consumer`, `Producer`)
4//! that every rust-camel component implements. Also re-exports commonly-used types
5//! from `camel-api` and `camel-endpoint` for component convenience.
6//!
7//! Main types: `Component`, `Endpoint`, `Consumer`, `ProducerContext`, `ExchangeEnvelope`, `ComponentBundle`, `PollingConsumer`.
8//! Main modules: `component`, `endpoint`, `consumer`, `producer`, `registrar`.
9
10pub mod bundle;
11pub mod component;
12pub mod component_context;
13pub mod consumer;
14pub mod endpoint;
15pub mod health_registry;
16pub mod runtime_observability;
17
18pub mod network_retry;
19pub mod producer;
20pub mod registrar;
21#[cfg(any(test, feature = "test-support"))]
22pub mod test_support;
23
24pub use bundle::ComponentBundle;
25pub use component::Component;
26pub use component_context::{ComponentContext, NoOpComponentContext};
27pub use consumer::{
28    ConcurrencyModel, Consumer, ConsumerContext, ExchangeEnvelope, SecurityContext,
29};
30pub use endpoint::{Endpoint, PollingConsumer};
31pub use health_registry::{
32    HealthCheckRegistry, NoOpHealthCheckRegistry, noop_health_check_registry,
33};
34pub use runtime_observability::RuntimeObservability;
35
36pub use network_retry::{
37    NetworkRetryPolicy, is_retryable_camel_error, retry_async, retry_async_cancelable,
38};
39pub use producer::ProducerContext;
40pub use registrar::ComponentRegistrar;
41#[cfg(any(test, feature = "test-support"))]
42pub use test_support::PanicRuntimeObservability;
43
44// Re-export camel-api types for component convenience
45pub use camel_api::{
46    AsyncHealthCheck, Body, BodyType, BoxProcessor, CamelError, CheckResult, Exchange,
47    HealthStatus, Message, RouteAction, RouteStatus, RuntimeCommand, RuntimeCommandBus,
48    RuntimeCommandResult, RuntimeHandle, RuntimeQuery, RuntimeQueryBus, RuntimeQueryResult,
49    StreamBody, StreamMetadata, Value,
50};
51
52// Re-export camel-endpoint types for component convenience
53pub use camel_endpoint::{UriComponents, UriConfig, parse_uri};
54// Expose a `uri` sub-module so crates using `#[uri_config(crate = "camel_component_api")]`
55// can resolve `camel_component_api::uri::parse_bool_param` etc.
56pub mod uri {
57    /// Parse a boolean URI parameter value (case-insensitive).
58    /// Accepts: "true"/"1"/"yes" → true; "false"/"0"/"no" → false.
59    pub fn parse_bool_param(s: &str) -> Result<bool, String> {
60        match s.to_lowercase().as_str() {
61            "true" | "1" | "yes" => Ok(true),
62            "false" | "0" | "no" => Ok(false),
63            _ => Err(format!("invalid boolean value: '{}'", s)),
64        }
65    }
66}