pub struct Environment<'a> {
pub home_dir: Cow<'a, Path>,
pub temp_dir: Cow<'a, Path>,
pub cache_dir: Cow<'a, Path>,
pub pkg_name: Cow<'a, str>,
}Expand description
Environment variables and system metadata.
Uses Cow (Copy-on-Write) to handle both owned paths/strings from the environment and static fallbacks efficiently without unnecessary allocations.
Fields§
§home_dir: Cow<'a, Path>§temp_dir: Cow<'a, Path>§cache_dir: Cow<'a, Path>§pkg_name: Cow<'a, str>Implementations§
Source§impl Environment<'_>
impl Environment<'_>
Sourcepub fn fallback() -> Environment<'static>
pub fn fallback() -> Environment<'static>
Returns a fallback environment config with static defaults.
Sourcepub fn new() -> WallSwitchResult<Environment<'static>>
pub fn new() -> WallSwitchResult<Environment<'static>>
Initializes the environment by gathering data from system variables.
This resolves the system home directory, temporary directory, and package name safely.
Sourcepub fn get_app_config_dir(&self) -> PathBuf
pub fn get_app_config_dir(&self) -> PathBuf
Returns the standard configuration directory based on target OS platform guidelines.
- On Unix-like systems (Linux/macOS), returns
~/.config/wallswitch. - On Windows systems, returns
%APPDATA%\wallswitch.
Sourcepub fn get_app_cache_dir(&self) -> PathBuf
pub fn get_app_cache_dir(&self) -> PathBuf
Returns the standard non-volatile user cache directory based on OS guidelines.
- On Unix-like systems, returns
~/.cache/wallswitch. - On Windows systems, returns
%LOCALAPPDATA%\wallswitch.
Sourcepub fn get_home_dir(&self) -> &Path
pub fn get_home_dir(&self) -> &Path
Returns a reference to the home directory path.
Sourcepub fn get_temp_dir(&self) -> &Path
pub fn get_temp_dir(&self) -> &Path
Returns a reference to the temporary directory path.
Sourcepub fn get_pkg_name(&self) -> &str
pub fn get_pkg_name(&self) -> &str
Returns a reference to the package name.
Auto Trait Implementations§
impl<'a> Freeze for Environment<'a>
impl<'a> RefUnwindSafe for Environment<'a>
impl<'a> Send for Environment<'a>
impl<'a> Sync for Environment<'a>
impl<'a> Unpin for Environment<'a>
impl<'a> UnsafeUnpin for Environment<'a>
impl<'a> UnwindSafe for Environment<'a>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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