pub struct EnvConfig {
pub database_url: Option<String>,
pub dotenv_loaded: bool,
pub dotenv_path: Option<String>,
pub database_url_source: Option<String>,
}Expand description
Result of loading environment configuration.
Fields§
§database_url: Option<String>Database URL resolved from environment (if found).
dotenv_loaded: boolWhether a .env file was successfully loaded.
dotenv_path: Option<String>Path to the .env file that was loaded (if any).
database_url_source: Option<String>Which environment variable the database URL came from (if any).
Implementations§
Source§impl EnvConfig
impl EnvConfig
Sourcepub fn load() -> Self
pub fn load() -> Self
Load environment configuration.
- Attempts to load
.envfile from current directory - Checks environment variables for database URL
§Example
use schema_risk::env::EnvConfig;
let env = EnvConfig::load();
if let Some(url) = &env.database_url {
println!("Found database URL from {}", env.database_url_source.as_deref().unwrap_or("unknown"));
}Sourcepub fn load_from_dir(dir: &Path) -> Self
pub fn load_from_dir(dir: &Path) -> Self
Load environment configuration from a specific directory.
Sourcepub fn resolve_db_url(
&self,
cli_url: Option<&str>,
config_url: Option<&str>,
) -> Option<String>
pub fn resolve_db_url( &self, cli_url: Option<&str>, config_url: Option<&str>, ) -> Option<String>
Sourcepub fn has_db_url(&self) -> bool
pub fn has_db_url(&self) -> bool
Check if a database URL is available from any source.
Sourcepub fn db_url_source_description(&self) -> Option<String>
pub fn db_url_source_description(&self) -> Option<String>
Get a human-readable description of where the database URL came from.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EnvConfig
impl RefUnwindSafe for EnvConfig
impl Send for EnvConfig
impl Sync for EnvConfig
impl Unpin for EnvConfig
impl UnsafeUnpin for EnvConfig
impl UnwindSafe for EnvConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more