BreakpadHandler

Struct BreakpadHandler 

Source
pub struct BreakpadHandler { /* private fields */ }

Implementations§

Source§

impl BreakpadHandler

Source

pub fn attach<P: AsRef<Path>>( crash_dir: P, install_opts: InstallOptions, on_crash: Box<dyn CrashEvent>, ) -> Result<Self, Error>

Sets up a breakpad handler to catch exceptions/signals, writing out a minidump to the designated directory if a crash occurs. Only one handler can be attached at a time

Examples found in repository?
examples/handle_crash.rs (lines 4-19)
1fn main() {
2    let cur_dir = std::env::current_dir().unwrap();
3
4    let _handler = breakpad_handler::BreakpadHandler::attach(
5        cur_dir,
6        breakpad_handler::InstallOptions::BothHandlers,
7        Box::new(|minidump_path: std::path::PathBuf| {
8            println!("Minidump written to {}", minidump_path.display());
9
10            match std::fs::remove_file(&minidump_path) {
11                Ok(_) => {
12                    println!("Removed {}", minidump_path.display());
13                }
14                Err(e) => {
15                    println!("Failed to remove {}: {}", minidump_path.display(), e);
16                }
17            }
18        }),
19    )
20    .unwrap();
21
22    #[allow(unsafe_code)]
23    unsafe {
24        if std::env::args().any(|a| a == "--crash") {
25            let ptr: *mut u8 = std::ptr::null_mut();
26            *ptr = 42;
27        }
28    }
29}

Trait Implementations§

Source§

impl Drop for BreakpadHandler

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for BreakpadHandler

Source§

impl Sync for BreakpadHandler

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.