pub fn init(mut self) -> Result<Shutdown, Error> {
        let mut lock = global_write();

        // make sure we aren't initializing Sentry twice
        if *lock {
            panic!("already initialized Sentry once")
        }

        // disolve `Options`, `sys::init` is going to take ownership now
        let options = if let Ownership::Owned(options) = self.raw.take().expect("use after free") {
            options
        } else {
            unreachable!("can't mutably borrow `Options`")
        };

        match unsafe { sys::init(options) } {
            0 => {
                *lock = true;

                // store `before_send` data so we can deallocate it later
                if let Some(before_send) = self.before_send.take() {
                    BEFORE_SEND
                        .set(Mutex::new(Some(before_send)))
                        .map_err(|_| ())
                        .expect("`BEFORE_SEND` was set once before");
                }

                drop(lock);

                Ok(Shutdown)
            }
            _ => Err(Error::Init),
        }
    }
/// Initializes the Sentry SDK with the specified options. Make sure to
/// capture the resulting [`Shutdown`], this makes sure to automatically
/// call [`shutdown`] when it drops.
///
/// # Errors
/// Fails with [`Error::Init`] if Sentry couldn't initialize - should only
/// occur in these situations:
/// - Fails to create database directory.
/// - Fails to lock database directory.
///
/// # Panics
/// Panics if `init` was already called once before.
///
/// # Examples
/// ```
/// # use sentry_contrib_native::Options;
/// # fn main() -> anyhow::Result<()> {
/// let _shutdown = Options::new().init()?;
/// # Ok(()) }
/// ```
Initializes the Sentry SDK with the specified options. Make sure to
capture the resulting [`Shutdown`], this makes sure to automatically
call [`shutdown`] when it drops.
Initializes the Sentry SDK with the specified options . Make sure to capture the resulting [ ` Shutdown ` ] this makes sure to automatically call [ ` shutdown ` ] when it drops .
pub fn init(mut self) -> Result<Shutdown, Error> {
        let mut lock = global_write();
        // make sure we aren't initializing Sentry twice
        if *lock {
            panic!("already initialized Sentry once")
        }
        // disolve `Options`, `sys::init` is going to take ownership now
        let options = if let Ownership::Owned(options) = self.raw.take().expect("use after free") {
            options
        } else {
            unreachable!("can't mutably borrow `Options`")
        };
        match unsafe { sys::init(options) } {
            0 => {
                *lock = true;
                // store `before_send` data so we can deallocate it later
                if let Some(before_send) = self.before_send.take() {
                    BEFORE_SEND
                        .set(Mutex::new(Some(before_send)))
                        .map_err(|_| ())
                        .expect("`BEFORE_SEND` was set once before");
                }
                drop(lock);
                Ok(Shutdown)
            }
            _ => Err(Error::Init),
        }
    }
pub fn init ( mut self ) -> Result < Shutdown , Error > { let mut lock = global_write ( ) ; // make sure we aren't initializing Sentry twice if * lock { panic ! ( " " ) } // disolve `Options`, `sys::init` is going to take ownership now let options = if let Ownership :: Owned ( options ) = self . raw . take ( ) . expect ( " " ) { options } else { unreachable ! ( " " ) } ; match unsafe { sys :: init ( options ) } { 0 => { * lock = true ; // store `before_send` data so we can deallocate it later if let Some ( before_send ) = self . before_send . take ( ) { BEFORE_SEND . set ( Mutex :: new ( Some ( before_send ) ) ) . map_err ( | _ | ( ) ) . expect ( " " ) ; } drop ( lock ) ; Ok ( Shutdown ) } _ => Err ( Error :: Init ) , } }
Initializes the Sentry SDK with the specified options.
Initializes the Sentry SDK with the specified options .
mut self
mut self
errors
Fails with [`Error::Init`] if Sentry couldn't initialize - should only
occur in these situations:
Fails to create database directory.
Fails to lock database directory.
Fails with [ ` Error :: Init ` ] if Sentry couldn ' t initialize - should only occur in these situations : Fails to create database directory . Fails to lock database directory .
panics
Panics if `init` was already called once before.
Panics if ` init ` was already called once before .
examples
None
use sentry_contrib_native::options;
None
fn main() -> anyhow::result<()> {
let _shutdown = Options::new().init()?.
let _shutdown = Options :: new () . init () ? .
ok(()) }
None