Skip to content

std::env

Status: experimental

Process environment, command-line arguments, working directory.

API details and source

The implementation source contains the complete declarations and implementation notes. The table below lists canonical Gossamer call signatures; every item name links directly to its implementation file.

Item Canonical signature or declaration Description
args fn args() -> Vec<String> Returns the program's command-line arguments.
current_dir fn current_dir() -> Result<String, io::Error> Returns the current working directory.
home_dir fn home_dir() -> Option<String> Returns the calling user's home directory if known.
program_name fn program_name() -> String Returns the path used to invoke the program (argv[0]).
set_current_dir fn set_current_dir(path: String) -> Result<(), io::Error> Changes the current working directory.
set_var fn set_var(name: String, value: String) -> () Sets an environment variable in the current process.
temp_dir fn temp_dir() -> String Returns the system's temporary directory.
unset_var fn unset_var(name: String) -> () Removes an environment variable from the current process.
var fn var(name: String) -> Option<String> Returns the value of an environment variable.