pub struct CrashHandler { /* private fields */ }
Expand description
A wrapper around a process closure that handles crashes by running the closure as a subprocess and invoking a crash handler closure if the subprocess fails.
Implementations§
Source§impl CrashHandler
impl CrashHandler
Sourcepub fn with_process(process: impl Fn() + 'static) -> Self
pub fn with_process(process: impl Fn() + 'static) -> Self
Create a new crash reporter from the given closure that runs a process.
Sourcepub fn child_flag(self, flag: impl Into<String>) -> Self
pub fn child_flag(self, flag: impl Into<String>) -> Self
Sets the command line flag that identifies a child process.
Sourcepub fn crash_handler(
self,
crash_handler: impl Fn(Output) -> Result<(), Box<dyn Error>> + 'static,
) -> Self
pub fn crash_handler( self, crash_handler: impl Fn(Output) -> Result<(), Box<dyn Error>> + 'static, ) -> Self
Sets the crash handler that is called when the process fails.
Sourcepub fn backtrace(self) -> Self
pub fn backtrace(self) -> Self
Sets the value of the RUST_BACKTRACE
environment variable in the
subprocess to 1
.
Sourcepub fn full_backtrace(self) -> Self
pub fn full_backtrace(self) -> Self
Sets the value of the RUST_BACKTRACE
environment variable in the
subprocess to full
.
Sourcepub fn run(&self) -> Result<bool, Box<dyn Error>>
pub fn run(&self) -> Result<bool, Box<dyn Error>>
Runs the configured process as a subprocess and handle crashes if the child flag is not present, otherwise run the process normally.
§Returns
Ok(true)
if the process ran successfully without errors.Ok(false)
if there was an error in the process (that was handled).Err
if there was an error spawning the process or handling an error in the process.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CrashHandler
impl !RefUnwindSafe for CrashHandler
impl !Send for CrashHandler
impl !Sync for CrashHandler
impl Unpin for CrashHandler
impl !UnwindSafe for CrashHandler
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