pub fn call_init<F>(&self, f: F) -> Result<(), Error>
    where
        F: FnOnce() -> bool,
    {
        match self.state.compare_exchange(
            Self::UNINITIALIZED,
            Self::INITIALIZING,
            Ordering::SeqCst,
            Ordering::SeqCst,
        ) {
            Err(Self::INITIALIZING) => {
                return Err(Error::InitializationInProgress);
            }
            Err(Self::INITIALIZED) => {
                return Err(Error::AlreadyInitialized);
            }
            _ => {}
        }

        let state = if f() {
            Self::INITIALIZED
        } else {
            Self::UNINITIALIZED
        };

        self.state.store(state, Ordering::SeqCst);

        Ok(())
    }
/// Performs an initialization routine.
///
/// The given closure will be executed if the current state is `UNINITIALIZED`.
/// Otherwise an Error will be returned.
///
/// If the closure returns `true`, the state will be changed to `INITIALIZED`.
/// If the closure returns `false`, the state will remain `UNINITIALIZED`.
Performs an initialization routine.
The given closure will be executed if the current state is `UNINITIALIZED`.
Otherwise an Error will be returned.

If the closure returns `true`, the state will be changed to `INITIALIZED`.
If the closure returns `false`, the state will remain `UNINITIALIZED`.
Performs an initialization routine . The given closure will be executed if the current state is ` UNINITIALIZED ` . Otherwise an Error will be returned . If the closure returns ` true ` the state will be changed to ` INITIALIZED ` . If the closure returns ` false ` the state will remain ` UNINITIALIZED ` .
pub fn call_init<F>(&self, f: F) -> Result<(), Error>
    where
        F: FnOnce() -> bool,
    {
        match self.state.compare_exchange(
            Self::UNINITIALIZED,
            Self::INITIALIZING,
            Ordering::SeqCst,
            Ordering::SeqCst,
        ) {
            Err(Self::INITIALIZING) => {
                return Err(Error::InitializationInProgress);
            }
            Err(Self::INITIALIZED) => {
                return Err(Error::AlreadyInitialized);
            }
            _ => {}
        }
        let state = if f() {
            Self::INITIALIZED
        } else {
            Self::UNINITIALIZED
        };
        self.state.store(state, Ordering::SeqCst);
        Ok(())
    }
pub fn call_init < F > ( & self , f : F ) -> Result < ( ) , Error > where F : FnOnce ( ) -> bool , { match self . state . compare_exchange ( Self :: UNINITIALIZED , Self :: INITIALIZING , Ordering :: SeqCst , Ordering :: SeqCst , ) { Err ( Self :: INITIALIZING ) => { return Err ( Error :: InitializationInProgress ) ; } Err ( Self :: INITIALIZED ) => { return Err ( Error :: AlreadyInitialized ) ; } _ => { } } let state = if f ( ) { Self :: INITIALIZED } else { Self :: UNINITIALIZED } ; self . state . store ( state , Ordering :: SeqCst ) ; Ok ( ( ) ) }
Performs an initialization routine.
Performs an initialization routine .
&self
f
F
&self
f
F