Feature Flags
Cargo feature flags for optional HDDS functionality.
Overview
HDDS uses Cargo features to enable optional functionality. This reduces binary size and compile time for applications that don't need all features.
Default Features
[dependencies]
# Clone: git clone https://git.hdds.io/hdds/hdds.git
hdds = { path = "../hdds/crates/hdds" } # Includes: xtypes, qos-loaders
| Feature | Description |
|---|---|
xtypes | XTypes type system (TypeIdentifier, TypeObject) |
qos-loaders | XML/YAML QoS profile loading |
All Features
[dependencies]
hdds = { path = "../hdds/crates/hdds", features = ["all"] }
Feature Reference
Core Features
| Feature | Dependencies | Description |
|---|---|---|
xtypes | md-5 | XTypes type system with MD5 type hashing |
type-lookup | xtypes | TypeLookup service (HDDS-to-HDDS only) |
dynamic-types | - | Runtime type construction (DynamicData) |
qos-loaders | roxmltree, serde, serde_yaml | Load QoS profiles from XML/YAML |
Transport Features
| Feature | Dependencies | Description |
|---|---|---|
quic | quinn, rustls | QUIC transport with 0-RTT, NAT traversal, connection migration |
tcp-tls | rustls, webpki-roots, rustls-pemfile | TLS encryption for TCP transport |
lowbw-lz4 | lz4_flex | LZ4 compression for low-bandwidth links |
Security Feature
| Feature | Dependencies | Description |
|---|---|---|
security | ring, x509-parser, pem, webpki, base64 | DDS Security (authentication, encryption, access control) |
Discovery Features
| Feature | Dependencies | Description |
|---|---|---|
cloud-discovery | reqwest, serde, serde_json, tokio | AWS/Azure/Consul discovery backends |
k8s | - | Kubernetes Headless Service discovery |
Communication Features
| Feature | Dependencies | Description |
|---|---|---|
rpc | tokio | DDS-RPC Request/Reply pattern |
Observability Features
| Feature | Dependencies | Description |
|---|---|---|
telemetry | - | Metrics collection and streaming |
logging | - | Compile-time configurable logging |
trace | logging | Function entry tracing (requires logging) |
Debugging Features
| Feature | Dependencies | Description |
|---|---|---|
rti-hexdump | - | Verbose RTI packet hex dumps |
bench-stress | - | Stress test benchmarks |
Vendor Dialect Features
| Feature | Description |
|---|---|
dialect-coredx | CoreDX DDS compatibility |
dialect-dust | Dust DDS compatibility |
dialect-gurum | Gurum DDS compatibility |
dialect-intercom | InterCOM DDS compatibility |
dialect-opensplice | OpenSplice DDS compatibility |
Usage Examples
Minimal (no optional features)
[dependencies]
hdds = { path = "../hdds/crates/hdds", default-features = false }
Security + Cloud Discovery
[dependencies]
hdds = { path = "../hdds/crates/hdds", features = ["security", "cloud-discovery"] }
Embedded/Constrained (no XML, no security)
[dependencies]
hdds = { path = "../hdds/crates/hdds", default-features = false, features = ["lowbw-lz4"] }
Full-Featured Development
[dependencies]
hdds = { path = "../hdds/crates/hdds", features = [
"security",
"cloud-discovery",
"tcp-tls",
"rpc",
"telemetry",
"logging",
"dynamic-types",
]}
Kubernetes Deployment
[dependencies]
hdds = { path = "../hdds/crates/hdds", features = ["k8s", "telemetry"] }
Feature Details
xtypes
Enables XTypes type system:
- TypeIdentifier and TypeObject
- Type equivalence checking
- MD5-based type hashing
use hdds::xtypes::{TypeIdentifier, TypeObject};
let type_id = TypeIdentifier::from_type::<SensorData>();
type-lookup
Enables TypeLookup service for runtime type discovery:
// Request type information from remote participant
let type_obj = participant.lookup_type(&type_id)?;
TypeLookup is HDDS-to-HDDS only. Other vendors use incompatible implementations.
dynamic-types
Enables runtime type construction:
use hdds::dynamic::{TypeDescriptorBuilder, DynamicData, PrimitiveKind};
let desc = TypeDescriptorBuilder::new("SensorReading")
.field("sensor_id", PrimitiveKind::U32)
.field("temperature", PrimitiveKind::F64)
.build();
let mut data = DynamicData::new(&Arc::new(desc));
data.set("sensor_id", 42u32)?;
security
Enables DDS Security plugins:
- Authentication (X.509 PKI)
- Encryption (AES-256-GCM)
- Access control (Permissions documents)
use hdds::security::{SecurityConfig, AuthenticationPlugin};
let config = SecurityConfig::builder()
.identity_ca("/path/to/ca.pem")
.identity_cert("/path/to/cert.pem")
.identity_key("/path/to/key.pem")
.build()?;
tcp-tls
Enables TLS encryption for TCP transport:
use hdds::transport::tcp::{TlsConfig, TlsVersion};
let tls = TlsConfig::builder()
.cert_file("/path/to/cert.pem")
.key_file("/path/to/key.pem")
.ca_file("/path/to/ca.pem")
.min_version(TlsVersion::Tls12)
.build()?;
lowbw-lz4
Enables LZ4 compression for low-bandwidth transport:
use hdds::transport::lowbw::LowBwConfig;
let config = LowBwConfig {
compression: true, // Enable LZ4
..Default::default()
};
cloud-discovery
Enables cloud service discovery backends:
use hdds::discovery::cloud::{AwsCloudMapConfig, ConsulConfig};
// AWS Cloud Map
let aws = AwsCloudMapConfig::new("my-namespace", "my-service");
// Consul
let consul = ConsulConfig::new("http://consul:8500", "hdds-service");
k8s
Enables Kubernetes DNS-based discovery (zero dependencies):
use hdds::discovery::k8s::K8sConfig;
let config = K8sConfig::new("hdds-headless.default.svc.cluster.local");
rpc
Enables DDS-RPC Request/Reply pattern:
use hdds::rpc::{ServiceClient, ServiceServer};
// Client
let client = ServiceClient::new(participant, "Calculator")?;
let result: i32 = client.call("add", (1, 2)).await?;
// Server
let server = ServiceServer::new(participant, "Calculator")?;
server.register("add", |a: i32, b: i32| a + b);
server.run().await?;
telemetry
Enables metrics collection and streaming:
use hdds::telemetry::{init_metrics, init_exporter};
let metrics = init_metrics();
let exporter = init_exporter("0.0.0.0:4242")?;
logging
Enables compile-time configurable logging:
use hdds::logging::{init_logger, ConsoleOutput, LogLevel};
init_logger(Arc::new(ConsoleOutput::new(LogLevel::Debug)), LogLevel::Debug);
info!("Application started");
Vendor Dialects
Enable compatibility with specific DDS vendors:
# For CoreDX interop
hdds = { path = "../hdds/crates/hdds", features = ["dialect-coredx"] }
Dialect features adjust:
- Participant announcement format
- QoS encoding quirks
- Discovery timing parameters
Binary Size Impact
Approximate binary size impact per feature (release build, LTO):
| Feature | Size Impact |
|---|---|
| Base (no features) | ~800 KB |
xtypes | +50 KB |
security | +200 KB |
tcp-tls | +150 KB |
cloud-discovery | +300 KB |
qos-loaders | +100 KB |
telemetry | +30 KB |
logging | +10 KB |
Related
- Configuration - Runtime configuration
- Environment Variables - Runtime settings
- Security - Security configuration