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