pub struct ExeReplaceGuard { /* private fields */ }Expand description
Windows can’t overwrite a running executable (the file is locked),
but it CAN rename it. Parking the running exe under a .old name
frees the original path so the cargo-dist installer’s Copy-Item
succeeds; the parked file is removed on the next start.
The guard is plain filesystem logic so it is unit-tested on every
platform; apply_with only activates it on Windows.
Implementations§
Source§impl ExeReplaceGuard
impl ExeReplaceGuard
Sourcepub fn park(exe: &Path) -> Result<Self>
pub fn park(exe: &Path) -> Result<Self>
Rename exe aside. Replaces any stale artifact from a
previous update first.
Sourcepub fn confirm_replaced(&self) -> Result<()>
pub fn confirm_replaced(&self) -> Result<()>
After the installer ran: did a new binary land at the original path? If not, the installer wrote somewhere else and a restart would find nothing to exec — the caller must roll back.
Auto Trait Implementations§
impl Freeze for ExeReplaceGuard
impl RefUnwindSafe for ExeReplaceGuard
impl Send for ExeReplaceGuard
impl Sync for ExeReplaceGuard
impl Unpin for ExeReplaceGuard
impl UnsafeUnpin for ExeReplaceGuard
impl UnwindSafe for ExeReplaceGuard
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.