Skip to main content

xds_core/
lib.rs

1//! # xds-core
2//!
3//! Core types, traits, and error handling for xDS control plane implementations.
4//!
5//! This crate provides the foundational types used across all other xDS crates:
6//!
7//! - [`XdsError`] - Comprehensive error type with proper gRPC status code mapping
8//! - [`ResourceVersion`] - Version tracking for xDS resources
9//! - [`NodeHash`] - Efficient node identification using FNV-1a hashing
10//! - [`Resource`] - Trait for implementing custom xDS resource types
11//! - [`TypeUrl`] - Type URL handling and constants
12//!
13//! ## Example
14//!
15//! ```rust
16//! use xds_core::{XdsError, NodeHash, ResourceVersion};
17//!
18//! // Create a node hash from a node ID
19//! let node = NodeHash::from_id("my-envoy-node");
20//!
21//! // Create a resource version
22//! let version = ResourceVersion::new("v1");
23//!
24//! // Check if version is empty (initial state)
25//! assert!(!version.is_empty());
26//! ```
27
28#![cfg_attr(docsrs, feature(doc_cfg))]
29#![deny(unsafe_code)]
30#![warn(missing_docs)]
31// Tests are allowed to use .unwrap() / .expect() / panic! freely; the
32// production-only warnings still apply.
33#![cfg_attr(test, allow(clippy::unwrap_used, clippy::expect_used, clippy::panic))]
34
35mod error;
36mod node;
37mod resource;
38mod type_url;
39mod version;
40
41pub use error::XdsError;
42pub use node::NodeHash;
43pub use resource::{
44    BoxResource, Resource, ResourceRegistry, ResourceTypeInfo, SharedResourceRegistry,
45};
46pub use type_url::TypeUrl;
47pub use version::ResourceVersion;
48
49/// Result type alias using [`XdsError`].
50pub type Result<T> = std::result::Result<T, XdsError>;
51
52/// Alias for Result to maintain backward compatibility.
53pub type XdsResult<T> = Result<T>;