[−][src]Struct darkweb_dotenv::Dotenv
Dotenv file loader
Implementations
impl Dotenv
[src]
pub fn new() -> Self
[src]
Creates a new instance of the Dotenv file loader.
Examples
# .env
DB_USER=root
DB_PASS=pass
use darkweb_dotenv::Dotenv; let mut dotenv = Dotenv::new(); dotenv.load(".env").unwrap(); let db_user = std::env::var("DB_USER").unwrap();
pub fn load<Path>(&mut self, path: Path) -> Result<(), Exception> where
Path: AsRef<str>,
[src]
Path: AsRef<str>,
Loads environment variables from file a .env
file.
Examples
use darkweb_dotenv::Dotenv; let mut dotenv = Dotenv::new(); dotenv.load(".env").unwrap();
Exceptions
Exception::FormatException
Exception::PathException
pub fn overload<Path>(&mut self, path: Path) -> Result<(), Exception> where
Path: AsRef<str>,
[src]
Path: AsRef<str>,
Loads environment variables from a .env
file and overwrites exiting environment variables.
Examples
use darkweb_dotenv::Dotenv; let mut dotenv = Dotenv::new(); dotenv.overload(".env").unwrap();
Exceptions
Exception::FormatException
Exception::PathException
pub fn load_env<Path, EnvKey, DefaultEnv>(
&mut self,
path: Path,
env_key: EnvKey,
default_env: DefaultEnv
) -> Result<(), Exception> where
Path: AsRef<str>,
EnvKey: AsRef<str>,
DefaultEnv: AsRef<str>,
[src]
&mut self,
path: Path,
env_key: EnvKey,
default_env: DefaultEnv
) -> Result<(), Exception> where
Path: AsRef<str>,
EnvKey: AsRef<str>,
DefaultEnv: AsRef<str>,
Loads environment-specific environment variables from multiple .env
files in an hierarchy.
The following files are loaded if they exist, the latter taking precedence over the former:
.env
--> committed environment defaults.env.local
--> uncommitted file with local overrides.env.{APP_ENV}
--> committed environment-specific defaults.env.{APP_ENV}.local
--> uncommitted environment-specific local overrides
Examples
use darkweb_dotenv::Dotenv; let mut dotenv = Dotenv::new(); dotenv.load_env(".env", "APP_ENV", "dev").unwrap();
Exceptions
Exception::FormatException
Exception::PathException
Auto Trait Implementations
impl RefUnwindSafe for Dotenv
impl Send for Dotenv
impl Sync for Dotenv
impl Unpin for Dotenv
impl UnwindSafe for Dotenv
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,