[−][src]Module palaver::env
Inspect the process's environment.
This library goes further than the stdlib to get arguments and environment
variables, including reading from /proc/self/cmdline
and similar.
This is helpful for library crates that don't want to require them to be
passed down to the library by the user; particularly if called from a
non-Rust application where the Rust stdlib hasn't had a chance to capture
them from the int main (int argc, char *argv[])
invocation thus breaking
std::env::args()
.
Examples
use std::io::Read; use palaver::env::exe; let mut current_binary = vec![]; exe().unwrap().read_to_end(&mut current_binary).unwrap(); println!("Current binary is {} bytes long!", current_binary.len());
use palaver::env; pub fn my_library_func() { let args = env::args(); let vars = env::vars(); }
Functions
args | Returns the arguments which this program was started with (normally passed via the command line). |
args_os | Returns the arguments which this program was started with (normally passed via the command line). |
exe | Returns a File of the currently running executable. Akin to |
exe_path | Returns the path of the currently running executable. On Linux this is |
vars | Returns a vector of (variable, value) pairs of strings, for all the environment variables of the current process. |
vars_os | Returns a vector of (variable, value) pairs of OS strings, for all the environment variables of the current process. |