objc2-local-authentication 0.3.2

Bindings to the LocalAuthentication framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;

use crate::*;

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/localauthentication/laenvironment?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct LAEnvironment;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for LAEnvironment {}
);

impl LAEnvironment {
    extern_methods!(
        /// The clients should use
        /// `currentUser`class property.
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;

        /// The clients should use
        /// `currentUser`class property.
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        /// Adds observer to monitor changes of the environment.
        ///
        /// The observer will be held weakly so its instance should be kept alive by the caller.
        #[unsafe(method(addObserver:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addObserver(&self, observer: &ProtocolObject<dyn LAEnvironmentObserver>);

        /// Removes the previously registered observer.
        ///
        /// If the observer is deallocated, it will be removed automatically.
        #[unsafe(method(removeObserver:))]
        #[unsafe(method_family = none)]
        pub unsafe fn removeObserver(&self, observer: &ProtocolObject<dyn LAEnvironmentObserver>);

        /// Environment of the current user.
        #[unsafe(method(currentUser))]
        #[unsafe(method_family = none)]
        pub unsafe fn currentUser() -> Retained<LAEnvironment>;

        #[cfg(feature = "LAEnvironmentState")]
        /// The environment state information.
        #[unsafe(method(state))]
        #[unsafe(method_family = none)]
        pub unsafe fn state(&self) -> Retained<LAEnvironmentState>;
    );
}

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/localauthentication/laenvironmentobserver?language=objc)
    pub unsafe trait LAEnvironmentObserver: NSObjectProtocol {
        #[cfg(feature = "LAEnvironmentState")]
        /// Called when there has been a change in the environment.
        ///
        /// Invoked on a queue private to LocalAuthentication framework. At the moment of invocation of this method,
        /// `LAEnvironment.state`already contains the new updated state.
        ///
        /// Parameter `oldState`: The old environment state (before update)
        #[optional]
        #[unsafe(method(environment:stateDidChangeFromOldState:))]
        #[unsafe(method_family = none)]
        unsafe fn environment_stateDidChangeFromOldState(
            &self,
            environment: &LAEnvironment,
            old_state: &LAEnvironmentState,
        );
    }
);