objc2-accounts 0.3.2

Bindings to the Accounts 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 objc2_foundation::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/accounts/acaccountcredentialrenewresult?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct ACAccountCredentialRenewResult(pub NSInteger);
impl ACAccountCredentialRenewResult {
    #[doc(alias = "ACAccountCredentialRenewResultRenewed")]
    pub const Renewed: Self = Self(0);
    #[doc(alias = "ACAccountCredentialRenewResultRejected")]
    pub const Rejected: Self = Self(1);
    #[doc(alias = "ACAccountCredentialRenewResultFailed")]
    pub const Failed: Self = Self(2);
}

unsafe impl Encode for ACAccountCredentialRenewResult {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for ACAccountCredentialRenewResult {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/accounts/acaccountstoresavecompletionhandler?language=objc)
#[cfg(feature = "block2")]
pub type ACAccountStoreSaveCompletionHandler = *mut block2::DynBlock<dyn Fn(Bool, *mut NSError)>;

/// [Apple's documentation](https://developer.apple.com/documentation/accounts/acaccountstoreremovecompletionhandler?language=objc)
#[cfg(feature = "block2")]
pub type ACAccountStoreRemoveCompletionHandler = *mut block2::DynBlock<dyn Fn(Bool, *mut NSError)>;

/// [Apple's documentation](https://developer.apple.com/documentation/accounts/acaccountstorerequestaccesscompletionhandler?language=objc)
#[cfg(feature = "block2")]
pub type ACAccountStoreRequestAccessCompletionHandler =
    *mut block2::DynBlock<dyn Fn(Bool, *mut NSError)>;

/// [Apple's documentation](https://developer.apple.com/documentation/accounts/acaccountstorecredentialrenewalhandler?language=objc)
#[cfg(feature = "block2")]
pub type ACAccountStoreCredentialRenewalHandler =
    *mut block2::DynBlock<dyn Fn(ACAccountCredentialRenewResult, *mut NSError)>;

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/accounts/acaccountstore?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[deprecated = "Use appropriate non-Apple SDK corresponding to the type of account you want to reference instead"]
    pub struct ACAccountStore;
);

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

impl ACAccountStore {
    extern_methods!(
        #[deprecated = "Use appropriate non-Apple SDK corresponding to the type of account you want to reference instead"]
        #[unsafe(method(accounts))]
        #[unsafe(method_family = none)]
        pub unsafe fn accounts(&self) -> Option<Retained<NSArray>>;

        #[cfg(feature = "ACAccount")]
        /// # Safety
        ///
        /// `identifier` might not allow `None`.
        #[deprecated = "Use appropriate non-Apple SDK corresponding to the type of account you want to reference instead"]
        #[unsafe(method(accountWithIdentifier:))]
        #[unsafe(method_family = none)]
        pub unsafe fn accountWithIdentifier(
            &self,
            identifier: Option<&NSString>,
        ) -> Option<Retained<ACAccount>>;

        #[cfg(feature = "ACAccountType")]
        /// # Safety
        ///
        /// `type_identifier` might not allow `None`.
        #[deprecated = "Use appropriate non-Apple SDK corresponding to the type of account you want to reference instead"]
        #[unsafe(method(accountTypeWithAccountTypeIdentifier:))]
        #[unsafe(method_family = none)]
        pub unsafe fn accountTypeWithAccountTypeIdentifier(
            &self,
            type_identifier: Option<&NSString>,
        ) -> Option<Retained<ACAccountType>>;

        #[cfg(feature = "ACAccountType")]
        /// # Safety
        ///
        /// `account_type` might not allow `None`.
        #[deprecated = "Use appropriate non-Apple SDK corresponding to the type of account you want to reference instead"]
        #[unsafe(method(accountsWithAccountType:))]
        #[unsafe(method_family = none)]
        pub unsafe fn accountsWithAccountType(
            &self,
            account_type: Option<&ACAccountType>,
        ) -> Option<Retained<NSArray>>;

        #[cfg(all(feature = "ACAccount", feature = "block2"))]
        /// # Safety
        ///
        /// - `account` might not allow `None`.
        /// - `completion_handler` must be a valid pointer.
        #[deprecated = "Use appropriate non-Apple SDK corresponding to the type of account you want to reference instead"]
        #[unsafe(method(saveAccount:withCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn saveAccount_withCompletionHandler(
            &self,
            account: Option<&ACAccount>,
            completion_handler: ACAccountStoreSaveCompletionHandler,
        );

        #[cfg(all(feature = "ACAccountType", feature = "block2"))]
        /// # Safety
        ///
        /// - `account_type` might not allow `None`.
        /// - `handler` must be a valid pointer.
        #[deprecated]
        #[unsafe(method(requestAccessToAccountsWithType:withCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn requestAccessToAccountsWithType_withCompletionHandler(
            &self,
            account_type: Option<&ACAccountType>,
            handler: ACAccountStoreRequestAccessCompletionHandler,
        );

        #[cfg(all(feature = "ACAccountType", feature = "block2"))]
        /// # Safety
        ///
        /// - `account_type` might not allow `None`.
        /// - `options` generic should be of the correct type.
        /// - `options` might not allow `None`.
        /// - `completion` must be a valid pointer.
        #[deprecated = "Use appropriate non-Apple SDK corresponding to the type of account you want to reference instead"]
        #[unsafe(method(requestAccessToAccountsWithType:options:completion:))]
        #[unsafe(method_family = none)]
        pub unsafe fn requestAccessToAccountsWithType_options_completion(
            &self,
            account_type: Option<&ACAccountType>,
            options: Option<&NSDictionary>,
            completion: ACAccountStoreRequestAccessCompletionHandler,
        );

        #[cfg(all(feature = "ACAccount", feature = "block2"))]
        /// # Safety
        ///
        /// - `account` might not allow `None`.
        /// - `completion_handler` must be a valid pointer.
        #[deprecated = "Use appropriate non-Apple SDK corresponding to the type of account you want to reference instead"]
        #[unsafe(method(renewCredentialsForAccount:completion:))]
        #[unsafe(method_family = none)]
        pub unsafe fn renewCredentialsForAccount_completion(
            &self,
            account: Option<&ACAccount>,
            completion_handler: ACAccountStoreCredentialRenewalHandler,
        );

        #[cfg(all(feature = "ACAccount", feature = "block2"))]
        /// # Safety
        ///
        /// - `account` might not allow `None`.
        /// - `completion_handler` must be a valid pointer.
        #[deprecated = "Use appropriate non-Apple SDK corresponding to the type of account you want to reference instead"]
        #[unsafe(method(removeAccount:withCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn removeAccount_withCompletionHandler(
            &self,
            account: Option<&ACAccount>,
            completion_handler: ACAccountStoreRemoveCompletionHandler,
        );
    );
}

/// Methods declared on superclass `NSObject`.
impl ACAccountStore {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/accounts/acaccountstoredidchangenotification?language=objc)
    #[deprecated = "Public notification deprecated. Internal clients, see private header for replacement"]
    pub static ACAccountStoreDidChangeNotification: Option<&'static NSString>;
}