llm_shield_cloud/
lib.rs

1//! Cloud abstraction layer for LLM Shield.
2//!
3//! This crate provides unified traits and types for interacting with cloud services
4//! across AWS, GCP, and Azure. It enables LLM Shield to leverage cloud-native features
5//! for secrets management, object storage, metrics, logging, and distributed tracing.
6//!
7//! # Architecture
8//!
9//! The crate defines trait-based abstractions for common cloud operations:
10//!
11//! - **Secret Management**: [`CloudSecretManager`] for AWS Secrets Manager, GCP Secret Manager, Azure Key Vault
12//! - **Object Storage**: [`CloudStorage`] for AWS S3, GCP Cloud Storage, Azure Blob Storage
13//! - **Observability**: [`CloudMetrics`], [`CloudLogger`], [`CloudTracer`] for cloud-native monitoring
14//!
15//! # Features
16//!
17//! This crate provides the core abstractions. Concrete implementations are provided by:
18//!
19//! - `llm-shield-cloud-aws` - AWS integrations (enable with `cloud-aws` feature)
20//! - `llm-shield-cloud-gcp` - GCP integrations (enable with `cloud-gcp` feature)
21//! - `llm-shield-cloud-azure` - Azure integrations (enable with `cloud-azure` feature)
22//!
23//! # Example
24//!
25//! ```rust,no_run
26//! use llm_shield_cloud::{CloudSecretManager, SecretValue, Result};
27//!
28//! async fn load_api_keys(
29//!     secret_manager: &dyn CloudSecretManager
30//! ) -> Result<Vec<String>> {
31//!     // Fetch API keys from cloud secret manager
32//!     let secret = secret_manager.get_secret("llm-shield/api-keys").await?;
33//!
34//!     // Parse the secret value
35//!     let api_keys: Vec<String> = serde_json::from_str(secret.as_string())?;
36//!
37//!     Ok(api_keys)
38//! }
39//! ```
40//!
41//! # Configuration
42//!
43//! Cloud integrations are configured via [`CloudConfig`]:
44//!
45//! ```yaml
46//! cloud:
47//!   provider: aws
48//!   aws:
49//!     region: us-east-1
50//!     secrets_manager:
51//!       enabled: true
52//!       cache_ttl_seconds: 300
53//!     s3:
54//!       bucket: llm-shield-models
55//! ```
56
57#![warn(missing_docs)]
58#![warn(clippy::all)]
59#![warn(clippy::pedantic)]
60#![allow(clippy::module_name_repetitions)]
61#![allow(clippy::missing_errors_doc)]
62#![allow(clippy::missing_panics_doc)]
63
64// Re-export core dependencies
65pub use async_trait::async_trait;
66
67// Module declarations
68pub mod config;
69pub mod error;
70pub mod observability;
71pub mod secrets;
72pub mod storage;
73
74// Re-export commonly used types
75pub use config::{
76    AzureConfig, AwsConfig, CloudConfig, CloudProvider, GcpConfig,
77};
78pub use error::{CloudError, Result};
79pub use observability::{
80    CloudLogger, CloudMetrics, CloudTracer, LogEntry, LogLevel, Metric, Span,
81};
82pub use secrets::{CloudSecretManager, SecretCache, SecretMetadata, SecretValue};
83pub use storage::{
84    CloudStorage, GetObjectOptions, ObjectMetadata, PutObjectOptions,
85};
86
87/// Library version.
88pub const VERSION: &str = env!("CARGO_PKG_VERSION");
89
90/// Library name.
91pub const LIB_NAME: &str = env!("CARGO_PKG_NAME");
92
93#[cfg(test)]
94mod tests {
95    use super::*;
96
97    #[test]
98    fn test_version() {
99        assert!(!VERSION.is_empty());
100        assert_eq!(LIB_NAME, "llm-shield-cloud");
101    }
102}