pub struct EnvSnapshot { /* private fields */ }Expand description
A snapshot of the shell environment at a point in time.
Implementations§
Source§impl EnvSnapshot
impl EnvSnapshot
Sourcepub fn new(vars: HashMap<String, String>, cwd: String) -> Self
pub fn new(vars: HashMap<String, String>, cwd: String) -> Self
Create a snapshot from the given variables and working directory.
Sourcepub fn capture_current() -> Self
pub fn capture_current() -> Self
Capture the current process environment, skipping bash-internal vars.
Sourcepub fn vars(&self) -> &HashMap<String, String>
pub fn vars(&self) -> &HashMap<String, String>
The environment variables in this snapshot.
§Examples
use reef::env_diff::EnvSnapshot;
let snap = EnvSnapshot::capture_current();
assert!(snap.vars().contains_key("HOME"));Sourcepub fn cwd(&self) -> &str
pub fn cwd(&self) -> &str
The working directory in this snapshot.
§Examples
use reef::env_diff::EnvSnapshot;
let snap = EnvSnapshot::capture_current();
assert!(!snap.cwd().is_empty());Sourcepub fn diff_into(&self, after: &EnvSnapshot, out: &mut String)
pub fn diff_into(&self, after: &EnvSnapshot, out: &mut String)
Diff two snapshots, writing fish commands into a single buffer.
Appends newline-separated commands like set -gx VAR value,
set -e VAR, or cd /new/path to out. Uses a single allocation
instead of one String per command.
Sourcepub fn diff(&self, after: &EnvSnapshot) -> String
pub fn diff(&self, after: &EnvSnapshot) -> String
Diff two snapshots, returning fish commands as a newline-separated string.
Convenience wrapper around diff_into that allocates
and returns a new String.
Trait Implementations§
Source§impl Clone for EnvSnapshot
impl Clone for EnvSnapshot
Source§fn clone(&self) -> EnvSnapshot
fn clone(&self) -> EnvSnapshot
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for EnvSnapshot
impl RefUnwindSafe for EnvSnapshot
impl Send for EnvSnapshot
impl Sync for EnvSnapshot
impl Unpin for EnvSnapshot
impl UnsafeUnpin for EnvSnapshot
impl UnwindSafe for EnvSnapshot
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more