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 cron_service;
19pub mod network_retry;
20pub mod producer;
21pub mod registrar;
22pub mod template_reload;
23#[cfg(any(test, feature = "test-support"))]
24pub mod test_support;
25pub mod tls_source;
26
27pub use bundle::ComponentBundle;
28pub use component::Component;
29pub use component_context::{ComponentContext, NoOpComponentContext};
30pub use consumer::{
31    ConcurrencyModel, Consumer, ConsumerContext, ConsumerStartupMode, ExchangeEnvelope,
32    SecurityContext, StartupReceiver, StartupSignal,
33};
34pub use endpoint::{Endpoint, PollingConsumer};
35pub use health_registry::{
36    HealthCheckRegistry, NoOpHealthCheckRegistry, noop_health_check_registry,
37};
38pub use runtime_observability::RuntimeObservability;
39
40pub use cron_service::{CronCallback, CronFire, CronSchedule, CronService};
41pub use network_retry::{
42    NetworkRetryPolicy, is_retryable_camel_error, retry_async, retry_async_cancelable,
43};
44pub use producer::ProducerContext;
45pub use registrar::ComponentRegistrar;
46#[cfg(any(test, feature = "test-support"))]
47pub use test_support::{NoopRuntimeObservability, PanicRuntimeObservability};
48
49// Re-export camel-api types for component convenience
50pub use camel_api::{
51    AsyncHealthCheck, Body, BodyType, BoxProcessor, CamelError, CheckResult, Exchange,
52    HealthStatus, Message, RouteAction, RouteStatus, RuntimeCommand, RuntimeCommandBus,
53    RuntimeCommandResult, RuntimeHandle, RuntimeQuery, RuntimeQueryBus, RuntimeQueryResult,
54    StreamBody, StreamMetadata, Value,
55};
56
57// Re-export camel-endpoint types for component convenience
58pub use camel_endpoint::{UriComponents, UriConfig, parse_uri};
59// Expose a `uri` sub-module so crates using `#[uri_config(crate = "camel_component_api")]`
60// can resolve `camel_component_api::uri::parse_bool_param` etc.
61pub mod uri {
62    /// Parse a boolean URI parameter value (case-insensitive).
63    /// Accepts: "true"/"1"/"yes" → true; "false"/"0"/"no" → false.
64    pub fn parse_bool_param(s: &str) -> Result<bool, String> {
65        match s.to_lowercase().as_str() {
66            "true" | "1" | "yes" => Ok(true),
67            "false" | "0" | "no" => Ok(false),
68            _ => Err(format!("invalid boolean value: '{}'", s)),
69        }
70    }
71}