Safe, human-friendly Restart Manager workflows for Rust applications that need to find, stop, and restart the Windows processes locking their files.
cargo add restart-managerThe default API is blocking. Enable the optional Tokio API when needed:
cargo add restart-manager --features tokioInspect the applications affected by replacing a file:
use restart_manager::RestartSession;
fn main() -> Result<(), restart_manager::Error> {
let mut session = RestartSession::new()?;
session.register_files([r"C:\product\component.dll"])?;
let applications = session.affected_applications()?;
eprintln!("reboot reasons: {:?}", applications.reboot_reasons());
for application in &applications {
eprintln!(
"{} (restartable: {})",
application.display_name().to_string_lossy(),
application.is_restartable(),
);
}
session.end()
}- Native operations are Windows-only. Public types remain available on other
targets, where OS operations return
ErrorKind::UnsupportedPlatform. - Shutdown produces an owned
RestartPendingrecovery value. It must be restarted or explicitly completed withleave_stopped; dropping it makes one best-effort restart attempt before ending the session. - Forced shutdown is opt-in and can cause applications to lose data.
- Restart Manager can relaunch only services and applications that registered themselves for restart.
- Tokio shutdown/restart futures use
tokio::AsyncOperationError<T>. Itsstate()isSomeonly when a callback-lease conflict proves that native work never began; worker failures returnNonerather than a misleading retryable typestate.
- API documentation
- Blocking examples and installer workflow
- Tokio installer example
- Changelog
- Security policy
- Contributing
Licensed under either MIT or Apache-2.0, at your option.