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