io_providers/env/local_provider.rs
1use std;
2use std::io;
3use std::path::{Path, PathBuf};
4use env;
5
6/// Provides access to the local environment (e.g. what the corresponding `std::env` functions
7/// would access).
8pub struct Local;
9
10impl Local {
11 /// Creates a new local environment provider.
12 pub fn new() -> Local {
13 Local
14 }
15}
16
17impl env::Provider for Local {
18 fn args(&self) -> Vec<String> {
19 std::env::args().collect()
20 }
21
22 fn current_dir(&self) -> io::Result<PathBuf> {
23 std::env::current_dir()
24 }
25
26 fn set_current_dir<P: AsRef<Path>>(&mut self, path: P) -> io::Result<()> {
27 std::env::set_current_dir(path)
28 }
29}