pub struct Env { /* private fields */ }Expand description
Everything the core may know about the process it runs in.
Implementations§
Source§impl Env
impl Env
Sourcepub fn builder(os: Os, home: impl Into<PathBuf>) -> EnvBuilder
pub fn builder(os: Os, home: impl Into<PathBuf>) -> EnvBuilder
Starts an environment for os whose user profile (~) is home.
On Windows home is FOLDERID_Profile, never $HOME.
pub fn os(&self) -> Os
Sourcepub fn known_folder(&self, folder: KnownFolder) -> Option<&Path>
pub fn known_folder(&self, folder: KnownFolder) -> Option<&Path>
A Windows Known Folder, if known.
Sourcepub fn var(&self, name: &str) -> Option<&OsStr>
pub fn var(&self, name: &str) -> Option<&OsStr>
An environment variable. Names are case-insensitive on Windows. Empty values read as unset, matching how Windows and the XDG spec treat them.
Sourcepub fn vars(&self) -> impl Iterator<Item = (&str, &OsStr)>
pub fn vars(&self) -> impl Iterator<Item = (&str, &OsStr)>
Every variable (names upper-cased on Windows), for the environment of a child process the core starts (the 1Password CLI).
Sourcepub fn with_var(&self, name: &str, value: impl Into<OsString>) -> Env
pub fn with_var(&self, name: &str, value: impl Into<OsString>) -> Env
A copy with name set to value, for the environment of one child
process (the 1Password CLI with a service account token).
Sourcepub fn now(&self) -> SystemTime
pub fn now(&self) -> SystemTime
The current time from the injected clock.
Source§impl Env
impl Env
Sourcepub fn from_process() -> Result<Env, CoreError>
pub fn from_process() -> Result<Env, CoreError>
Builds the environment of the running process (the CLI and the app;
never tests). On Windows the profile and app data folders come from
USERPROFILE, LOCALAPPDATA and APPDATA when set (hermetic tests
of the binaries set them), else from the Known Folders; HOME is
never used there.