pub struct CurrentExecutable { /* private fields */ }Expand description
The exact executable that is currently running, bound once to a canonical target.
Binding resolves symlinks, so an invocation through a link updates the real image and never overwrites the link object. It also proves that the target is a regular file beneath a real directory and records an identity for it: on Unix that is device plus inode, and on every platform it is the SHA-256 of the image’s bytes.
The content digest is what makes the binding safe on Windows. A file identity there needs handle-based FFI, which this crate forbids, so a path-only recheck would silently accept an image swapped in between binding and commit. Content equality is the strongest identity provable with safe code on every platform, and a mismatch fails closed.
Implementations§
Source§impl CurrentExecutable
impl CurrentExecutable
Sourcepub fn resolve() -> Result<Self>
pub fn resolve() -> Result<Self>
Resolves and binds the running executable from the process environment.
std::env::current_exe is only a starting point: on some platforms it
reports the invocation path, which may traverse symlinks. The result is
always canonicalized and re-proven before it is used for mutation.
§Errors
Returns Error::Io when the running executable cannot be reported or
canonicalized, Error::InvalidInput when the resolved path is not
absolute or has no parent directory, and Error::DestinationConflict
when the resolved target is not a regular, non-symlinked file beneath a
real directory — including a hard-linked image, whose exact identity
cannot be proven.
Sourcepub fn bind(executable: impl Into<PathBuf>) -> Result<Self>
pub fn bind(executable: impl Into<PathBuf>) -> Result<Self>
Binds an already-known executable path, applying the same proof rules as
resolve.
This is the seam a child-process fixture uses to address a specific
image; production callers normally use resolve.
§Errors
Returns Error::InvalidInput when executable is not an absolute
path, when the canonicalized target is empty, or when the target has
no parent directory or no file name; Error::Io when the target or
its directory cannot be read or canonicalized; and
Error::DestinationConflict when the target is not a regular,
non-symlinked file beneath a real directory — including a hard-linked
image, whose exact identity cannot be proven.
Sourcepub fn installation_root(&self) -> &Path
pub fn installation_root(&self) -> &Path
Returns the executable’s own directory, which is the installation root
used by crate::InstallPlan::for_current_executable.
The whole self-update transaction stays inside this directory, so no write authority above it is ever required.
Sourcepub fn destination_name(&self) -> &Path
pub fn destination_name(&self) -> &Path
Returns the file name used as the single destination member, relative to
installation_root.
Sourcepub fn destination(&self) -> PathBuf
pub fn destination(&self) -> PathBuf
Returns the absolute destination path of the running image.