Skip to main content

CurrentExecutable

Struct CurrentExecutable 

Source
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

Source

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.

Source

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.

Source

pub fn target(&self) -> &Path

Returns the canonical live path that will be replaced.

Source

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.

Source

pub fn destination_name(&self) -> &Path

Returns the file name used as the single destination member, relative to installation_root.

Source

pub fn destination(&self) -> PathBuf

Returns the absolute destination path of the running image.

Trait Implementations§

Source§

impl Clone for CurrentExecutable

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CurrentExecutable

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for CurrentExecutable

Source§

impl PartialEq for CurrentExecutable

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CurrentExecutable

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.