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