1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//! # KeyEnv Rust SDK
//!
//! Official Rust SDK for [KeyEnv](https://keyenv.dev) - Secrets management made simple.
//!
//! ## Quick Start
//!
//! ```rust,no_run
//! use keyenv::KeyEnv;
//! use std::env;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), keyenv::Error> {
//! let client = KeyEnv::builder()
//! .token(env::var("KEYENV_TOKEN").expect("KEYENV_TOKEN not set"))
//! .build()?;
//!
//! // Load secrets into environment
//! client.load_env("your-project-id", "production").await?;
//!
//! println!("{}", env::var("DATABASE_URL").unwrap());
//! Ok(())
//! }
//! ```
//!
//! ## Loading Secrets
//!
//! ### Load into Environment
//!
//! ```rust,no_run
//! # use keyenv::KeyEnv;
//! # async fn example(client: &KeyEnv) -> Result<(), keyenv::Error> {
//! let count = client.load_env("project-id", "production").await?;
//! println!("Loaded {} secrets", count);
//! # Ok(())
//! # }
//! ```
//!
//! ### Export as HashMap
//!
//! ```rust,no_run
//! # use keyenv::KeyEnv;
//! # async fn example(client: &KeyEnv) -> Result<(), keyenv::Error> {
//! let secrets = client.export_secrets_as_map("project-id", "production").await?;
//! println!("{}", secrets.get("DATABASE_URL").unwrap());
//! # Ok(())
//! # }
//! ```
//!
//! ## Managing Secrets
//!
//! ```rust,no_run
//! # use keyenv::KeyEnv;
//! # async fn example(client: &KeyEnv) -> Result<(), keyenv::Error> {
//! // Get a secret
//! let secret = client.get_secret("project-id", "production", "DATABASE_URL").await?;
//! println!("{}", secret.value);
//!
//! // Set a secret
//! client.set_secret("project-id", "production", "API_KEY", "sk_live_...").await?;
//!
//! // Delete a secret
//! client.delete_secret("project-id", "production", "OLD_KEY").await?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Error Handling
//!
//! ```rust,no_run
//! use keyenv::{KeyEnv, Error};
//!
//! # async fn example(client: &KeyEnv) -> Result<(), keyenv::Error> {
//! match client.get_secret("project-id", "production", "MISSING_KEY").await {
//! Ok(secret) => println!("{}", secret.value),
//! Err(Error::Api { status, message, .. }) => {
//! match status {
//! 401 => eprintln!("Invalid or expired token"),
//! 403 => eprintln!("Access denied"),
//! 404 => eprintln!("Secret not found"),
//! _ => eprintln!("Error {}: {}", status, message),
//! }
//! }
//! Err(e) => eprintln!("Error: {}", e),
//! }
//! # Ok(())
//! # }
//! ```
//!
//! ## Caching
//!
//! Enable caching for better performance in serverless environments:
//!
//! ```rust,no_run
//! use keyenv::KeyEnv;
//! use std::time::Duration;
//!
//! # fn example() -> Result<(), keyenv::Error> {
//! let client = KeyEnv::builder()
//! .token("your-token")
//! .cache_ttl(Duration::from_secs(300)) // 5 minutes
//! .build()?;
//! # Ok(())
//! # }
//! ```
pub use ;
pub use ;
pub use ;