#[cfg(all(feature = "std", feature = "unsafe_thread"))]
use crate::_dep::_std::env::{remove_var, set_var};
#[allow(deprecated, reason = "WAIT for official undeprecation of home_dir")]
#[cfg(feature = "std")]
use crate::{
_dep::_std::env::{
args, args_os, current_dir, current_exe, home_dir, join_paths, set_current_dir,
split_paths, temp_dir, var, var_os, vars, vars_os,
},
IoResult, JoinPathsError, OsStr, OsString, Path, PathBuf, VarError,
};
#[cfg_attr(not(feature = "__force_miri_dst"), cfg(not(miri)))]
#[cfg(all(feature = "std", feature = "unsafe_ffi"))]
use crate::{IterArgsOsRef, args_os_ref_iter};
#[doc = crate::_tags!(namespace)]
#[doc = crate::_doc_meta!{location("sys/os")}]
#[derive(Debug)]
pub struct Env;
impl Env {
pub const TARGET: &str = env!("DEVELA_TARGET");
pub const ARCH: &str = env!("DEVELA_TARGET_ARCH");
pub const OS: &str = env!("DEVELA_TARGET_OS");
pub const VENDOR: &str = env!("DEVELA_TARGET_VENDOR");
pub const FAMILY: &str = env!("DEVELA_TARGET_FAMILY");
pub const FAMILIES: &str = env!("DEVELA_TARGET_FAMILIES");
pub const ENV: &str = env!("DEVELA_TARGET_ENV");
pub const ABI: &str = env!("DEVELA_TARGET_ABI");
pub const ENDIAN: &str = env!("DEVELA_TARGET_ENDIAN");
pub const POINTER_WIDTH: &str = env!("DEVELA_TARGET_POINTER_WIDTH");
pub const DLL_PREFIX: &str = env!("DEVELA_DLL_PREFIX");
pub const DLL_EXTENSION: &str = env!("DEVELA_DLL_EXTENSION");
pub const DLL_SUFFIX: &str = env!("DEVELA_DLL_SUFFIX");
pub const EXE_EXTENSION: &str = env!("DEVELA_EXE_EXTENSION");
pub const EXE_SUFFIX: &str = env!("DEVELA_EXE_SUFFIX");
}
#[cfg(feature = "std")]
#[cfg_attr(nightly_doc, doc(cfg(feature = "std")))]
impl Env {
#[inline(always)]
pub fn args() -> ::std::env::Args {
args()
}
#[inline(always)]
pub fn args_os() -> ::std::env::ArgsOs {
args_os()
}
#[doc = crate::_doc_warn_miri!(tag)]
#[cfg_attr(not(feature = "__force_miri_dst"), cfg(not(miri)))]
#[doc = crate::_doc_vendor!("argv")]
#[cfg(all(feature = "std", feature = "unsafe_ffi"))]
#[cfg_attr(nightly_doc, doc(cfg(all(feature = "std", feature = "unsafe_ffi"))))]
pub fn args_os_ref() -> IterArgsOsRef {
args_os_ref_iter()
}
}
#[cfg(feature = "std")]
#[cfg_attr(nightly_doc, doc(cfg(feature = "std")))]
impl Env {
pub fn var<K: AsRef<OsStr>>(key: K) -> Result<String, VarError> {
var(key)
}
pub fn vars() -> ::std::env::Vars {
vars()
}
pub fn var_os<K: AsRef<OsStr>>(key: K) -> Option<OsString> {
var_os(key)
}
pub fn vars_os() -> ::std::env::VarsOs {
vars_os()
}
#[cfg(all(not(feature = "safe_sys"), feature = "unsafe_thread"))]
#[cfg_attr(nightly_doc, doc(cfg(feature = "unsafe_thread")))]
pub unsafe fn remove_var<K: AsRef<OsStr>>(key: K) {
unsafe { remove_var(key) }
}
#[cfg(all(not(feature = "safe_sys"), feature = "unsafe_thread"))]
#[cfg_attr(nightly_doc, doc(cfg(feature = "unsafe_thread")))]
pub unsafe fn set_var<K: AsRef<OsStr>, V: AsRef<OsStr>>(key: K, value: V) {
unsafe { set_var(key, value) }
}
}
#[cfg(feature = "std")]
#[cfg_attr(nightly_doc, doc(cfg(feature = "std")))]
impl Env {
pub fn current_exe() -> IoResult<PathBuf> {
current_exe()
}
pub fn current_dir() -> IoResult<PathBuf> {
current_dir()
}
pub fn set_current_dir<P: AsRef<Path>>(path: P) -> IoResult<()> {
set_current_dir(path)
}
#[allow(deprecated, reason = "WAIT for official undeprecation")]
pub fn home_dir() -> Option<PathBuf> {
home_dir()
}
pub fn temp_dir() -> PathBuf {
temp_dir()
}
pub fn join_paths<I, T>(paths: I) -> Result<OsString, JoinPathsError>
where
I: IntoIterator<Item = T>,
T: AsRef<OsStr>,
{
join_paths(paths)
}
pub fn split_paths<T: AsRef<OsStr> + ?Sized>(unparsed: &T) -> ::std::env::SplitPaths<'_> {
split_paths(unparsed)
}
}