pub trait KeyFromEnv {
const KEY_NAME: &'static str;
// Provided methods
fn find_key() -> Option<String> { ... }
fn find_key_with_user() -> String { ... }
fn prompt_save_to_env() -> bool { ... }
fn read_single_key() -> Result<String, Box<dyn Error>> { ... }
fn save_to_env_file(api_key: &str) -> Result<(), Box<dyn Error>> { ... }
}
Expand description
Trait for types that can retrieve their configuration key from environment variables
Required Associated Constants§
Provided Methods§
Sourcefn find_key() -> Option<String>
fn find_key() -> Option<String>
Find the API key by checking environment variables first, then .env file
Sourcefn find_key_with_user() -> String
fn find_key_with_user() -> String
Find the API key with user fallback - waits 15 seconds for user input then panics
Sourcefn prompt_save_to_env() -> bool
fn prompt_save_to_env() -> bool
Prompt user if they want to save the API key to .env file Uses single keystroke detection with fallback to Enter
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.