secret_store_sdk/
lib.rs

1//! XJP Secret Store SDK for Rust
2//!
3//! A comprehensive SDK for interacting with the XJP Secret Store service,
4//! providing secure storage and retrieval of secrets, configuration values,
5//! and sensitive data.
6//!
7//! # Features
8//!
9//! - Async/await support with tokio runtime
10//! - Automatic retries with exponential backoff
11//! - Built-in caching with ETag/304 support
12//! - Multiple authentication methods (Bearer, API Key, XJP Key)
13//! - Batch operations with transactional support
14//! - Environment export in multiple formats
15//! - Version management and rollback
16//! - Comprehensive error handling
17//! - Secure value handling with zeroization
18//!
19//! # Example
20//!
21//! ```no_run
22//! use secret_store_sdk::{Client, ClientBuilder, Auth};
23//!
24//! #[tokio::main]
25//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
26//!     let client = ClientBuilder::new("https://secret.example.com")
27//!         .auth(Auth::bearer("your-api-key"))
28//!         .build()?;
29//!
30//!     let secret = client.get_secret("production", "database-url", Default::default()).await?;
31//!     println!("Secret version: {}", secret.version);
32//!
33//!     Ok(())
34//! }
35//! ```
36
37#![deny(
38    missing_docs,
39    missing_debug_implementations,
40    unsafe_code,
41    unused_results,
42    warnings
43)]
44#![cfg_attr(docsrs, feature(doc_cfg))]
45
46mod auth;
47mod cache;
48mod client;
49mod config;
50mod endpoints;
51mod errors;
52mod models;
53/// Telemetry and observability support
54#[cfg(feature = "metrics")]
55pub mod telemetry;
56
57#[cfg(not(feature = "metrics"))]
58mod telemetry;
59mod util;
60
61pub use auth::{Auth, TokenProvider};
62pub use cache::{CacheConfig, CacheStats};
63pub use client::Client;
64pub use config::{ClientBuilder, ClientConfig};
65pub use errors::{Error, ErrorKind, Result};
66pub use models::*;
67
68// Re-export commonly used types
69pub use secrecy::SecretString;
70
71/// SDK version, matches Cargo.toml version
72pub const VERSION: &str = env!("CARGO_PKG_VERSION");
73
74/// Default timeout in milliseconds
75pub const DEFAULT_TIMEOUT_MS: u64 = 30_000;
76
77/// Default number of retries
78pub const DEFAULT_RETRIES: u32 = 3;
79
80/// Maximum cache entries
81pub const DEFAULT_CACHE_MAX_ENTRIES: u64 = 10_000;
82
83/// Default cache TTL in seconds
84pub const DEFAULT_CACHE_TTL_SECS: u64 = 300;
85
86#[cfg(test)]
87mod tests {
88    use super::*;
89
90    #[test]
91    fn test_version() {
92        // VERSION is a compile-time constant from CARGO_PKG_VERSION
93        // which is never empty, so we just verify it exists
94        assert_eq!(VERSION, env!("CARGO_PKG_VERSION"));
95    }
96}