rok::std::env
rok::std::env (stdlib spec 306): arguments, environment variables, directories, exit.
set_var has no global lock: call it before spawning threads (306.3).
Names and values from the OS are bytes (Windows: its UTF-16 as WTF-8);
var / vars / args hand out the UTF-8 ones as str, the *_os
forms raw.
Structs
RawStr
pub struct RawStrBytes from the OS that need not be UTF-8 (args_os, var_os).
pub const fn len(self) -> usizeByte length.
pub const fn is_empty(self) -> boolpub const fn to_str(self) throws (Utf8Error) -> strThe bytes as text; throws if they are not UTF-8.
pub const fn as_bytes(self) -> List<u8>A copy of the bytes.
pub fn from_wide(wide: List<u16>) -> RawStrUTF-16 units from the OS, lone surrogates allowed.
pub fn as_wide(self) -> List<u16>The UTF-16 units (a copy, like
as_bytes).
Trait implementations 2
impl PartialEq for RawStrimpl Debug for RawStr
Vars
pub struct VarsTrait implementations 1
impl Iterator for Vars
VarsOs
pub struct VarsOsTrait implementations 1
impl Iterator for VarsOs
JoinPathsError
pub struct JoinPathsErrorA join_paths entry that holds the separator.
pub path: str
Trait implementations 3
impl Display for JoinPathsErrorimpl Debug for JoinPathsErrorimpl Error for JoinPathsError
Enums
VarError
pub enum VarErrorWhy var gave no str.
NotPresentThe variable does not exist.
NotUnicodeIts value is not UTF-8 (read it with
var_os).
Trait implementations 3
impl Display for VarErrorimpl Debug for VarErrorimpl Error for VarError
Functions
exit
pub const fn exit(code: i32) -> !Exit the process now with code (refs-lang 4.16.4); finally and
Drop do not run.
args
pub fn args() -> List<str>Command-line arguments; [0] is the program name.
args_os
pub fn args_os() -> List<RawStr>The arguments as raw OS bytes.
var
pub fn var(name: str) throws (VarError) -> strname's value; NotPresent when unset, NotUnicode when not UTF-8.
var_os
pub fn var_os(name: str) -> RawStr | nonename's value as raw bytes, or none.
set_var
pub fn set_var(name: str, value: str)remove_var
pub fn remove_var(name: str)vars
pub const fn vars() -> VarsEvery (name, value) pair, a snapshot taken lazily as it goes.
vars_os
pub const fn vars_os() -> VarsOsvars as raw OS bytes (names and values need not be UTF-8).
current_dir
pub fn current_dir() throws (IoError) -> Pathset_current_dir
pub fn set_current_dir<P: AsPath>(path: P) throws (IoError)home_dir
pub fn home_dir() -> Path | none$HOME (Windows: %USERPROFILE%).
temp_dir
pub fn temp_dir() -> Path$TMPDIR, else /tmp. Windows: the first set of %TMP%, %TEMP%,
%USERPROFILE%, %SystemRoot% (as GetTempPath2W).
config_dir
pub fn config_dir() -> Path | nonePer-user configuration: ~/Library/Application Support,
%APPDATA%, or $XDG_CONFIG_HOME / ~/.config.
cache_dir
pub fn cache_dir() -> Path | nonePer-user cache: ~/Library/Caches, %LOCALAPPDATA%, or
$XDG_CACHE_HOME / ~/.cache.
data_dir
pub fn data_dir() -> Path | nonePer-user data: ~/Library/Application Support, %APPDATA%, or
$XDG_DATA_HOME / ~/.local/share.
split_paths
pub const fn split_paths(paths: str) -> List<Path>paths split on : (Windows: ;, " quoting dropped); empty
pieces dropped.
join_paths
pub const fn join_paths<I: Iterator<Item = Path>>(paths: I) throws (JoinPathsError) -> strpaths joined with : (Windows: ;), the PATH form; throws if one
holds the separator (or, on Windows, a ").
current_exe
pub fn current_exe() throws (IoError) -> PathThe running executable's absolute path.
pid
pub fn pid() -> u32parent_pid
pub fn parent_pid() -> u32 | none