objc2-cloud-kit 0.2.2

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

use crate::*;

extern "C" {
    pub static CKCurrentUserDefaultName: &'static NSString;
}

extern "C" {
    pub static CKOwnerDefaultName: &'static NSString;
}

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct CKContainer;

    unsafe impl ClassType for CKContainer {
        type Super = NSObject;
        type Mutability = InteriorMutable;
    }
);

unsafe impl Send for CKContainer {}

unsafe impl Sync for CKContainer {}

unsafe impl NSObjectProtocol for CKContainer {}

extern_methods!(
    unsafe impl CKContainer {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Retained<Self>;

        #[method_id(@__retain_semantics Other defaultContainer)]
        pub unsafe fn defaultContainer() -> Retained<CKContainer>;

        #[method_id(@__retain_semantics Other containerWithIdentifier:)]
        pub unsafe fn containerWithIdentifier(
            container_identifier: &NSString,
        ) -> Retained<CKContainer>;

        #[method_id(@__retain_semantics Other containerIdentifier)]
        pub unsafe fn containerIdentifier(&self) -> Option<Retained<NSString>>;

        #[cfg(feature = "CKOperation")]
        #[method(addOperation:)]
        pub unsafe fn addOperation(&self, operation: &CKOperation);
    }
);

extern_methods!(
    /// Database
    unsafe impl CKContainer {
        #[cfg(feature = "CKDatabase")]
        #[method_id(@__retain_semantics Other privateCloudDatabase)]
        pub unsafe fn privateCloudDatabase(&self) -> Retained<CKDatabase>;

        #[cfg(feature = "CKDatabase")]
        #[method_id(@__retain_semantics Other publicCloudDatabase)]
        pub unsafe fn publicCloudDatabase(&self) -> Retained<CKDatabase>;

        #[cfg(feature = "CKDatabase")]
        #[method_id(@__retain_semantics Other sharedCloudDatabase)]
        pub unsafe fn sharedCloudDatabase(&self) -> Retained<CKDatabase>;

        #[cfg(feature = "CKDatabase")]
        #[method_id(@__retain_semantics Other databaseWithDatabaseScope:)]
        pub unsafe fn databaseWithDatabaseScope(
            &self,
            database_scope: CKDatabaseScope,
        ) -> Retained<CKDatabase>;
    }
);

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CKAccountStatus(pub NSInteger);
impl CKAccountStatus {
    #[doc(alias = "CKAccountStatusCouldNotDetermine")]
    pub const CouldNotDetermine: Self = Self(0);
    #[doc(alias = "CKAccountStatusAvailable")]
    pub const Available: Self = Self(1);
    #[doc(alias = "CKAccountStatusRestricted")]
    pub const Restricted: Self = Self(2);
    #[doc(alias = "CKAccountStatusNoAccount")]
    pub const NoAccount: Self = Self(3);
    #[doc(alias = "CKAccountStatusTemporarilyUnavailable")]
    pub const TemporarilyUnavailable: Self = Self(4);
}

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

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

extern "C" {
    pub static CKAccountChangedNotification: &'static NSString;
}

extern_methods!(
    /// AccountStatus
    unsafe impl CKContainer {
        #[cfg(feature = "block2")]
        #[method(accountStatusWithCompletionHandler:)]
        pub unsafe fn accountStatusWithCompletionHandler(
            &self,
            completion_handler: &block2::Block<dyn Fn(CKAccountStatus, *mut NSError)>,
        );
    }
);

// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CKApplicationPermissions(pub NSUInteger);
bitflags::bitflags! {
    impl CKApplicationPermissions: NSUInteger {
#[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
        const CKApplicationPermissionUserDiscoverability = 1<<0;
    }
}

unsafe impl Encode for CKApplicationPermissions {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

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

// NS_ENUM
#[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CKApplicationPermissionStatus(pub NSInteger);
impl CKApplicationPermissionStatus {
    #[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
    #[doc(alias = "CKApplicationPermissionStatusInitialState")]
    pub const InitialState: Self = Self(0);
    #[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
    #[doc(alias = "CKApplicationPermissionStatusCouldNotComplete")]
    pub const CouldNotComplete: Self = Self(1);
    #[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
    #[doc(alias = "CKApplicationPermissionStatusDenied")]
    pub const Denied: Self = Self(2);
    #[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
    #[doc(alias = "CKApplicationPermissionStatusGranted")]
    pub const Granted: Self = Self(3);
}

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

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

#[cfg(feature = "block2")]
pub type CKApplicationPermissionBlock =
    *mut block2::Block<dyn Fn(CKApplicationPermissionStatus, *mut NSError)>;

extern_methods!(
    /// ApplicationPermission
    unsafe impl CKContainer {
        #[cfg(feature = "block2")]
        #[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
        #[method(statusForApplicationPermission:completionHandler:)]
        pub unsafe fn statusForApplicationPermission_completionHandler(
            &self,
            application_permission: CKApplicationPermissions,
            completion_handler: CKApplicationPermissionBlock,
        );

        #[cfg(feature = "block2")]
        #[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
        #[method(requestApplicationPermission:completionHandler:)]
        pub unsafe fn requestApplicationPermission_completionHandler(
            &self,
            application_permission: CKApplicationPermissions,
            completion_handler: CKApplicationPermissionBlock,
        );
    }
);

extern_methods!(
    /// UserRecords
    unsafe impl CKContainer {
        #[cfg(all(feature = "CKRecordID", feature = "block2"))]
        #[method(fetchUserRecordIDWithCompletionHandler:)]
        pub unsafe fn fetchUserRecordIDWithCompletionHandler(
            &self,
            completion_handler: &block2::Block<dyn Fn(*mut CKRecordID, *mut NSError)>,
        );

        #[cfg(all(feature = "CKUserIdentity", feature = "block2"))]
        #[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
        #[method(discoverAllIdentitiesWithCompletionHandler:)]
        pub unsafe fn discoverAllIdentitiesWithCompletionHandler(
            &self,
            completion_handler: &block2::Block<dyn Fn(*mut NSArray<CKUserIdentity>, *mut NSError)>,
        );

        #[cfg(all(feature = "CKUserIdentity", feature = "block2"))]
        #[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
        #[method(discoverUserIdentityWithEmailAddress:completionHandler:)]
        pub unsafe fn discoverUserIdentityWithEmailAddress_completionHandler(
            &self,
            email: &NSString,
            completion_handler: &block2::Block<dyn Fn(*mut CKUserIdentity, *mut NSError)>,
        );

        #[cfg(all(feature = "CKUserIdentity", feature = "block2"))]
        #[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
        #[method(discoverUserIdentityWithPhoneNumber:completionHandler:)]
        pub unsafe fn discoverUserIdentityWithPhoneNumber_completionHandler(
            &self,
            phone_number: &NSString,
            completion_handler: &block2::Block<dyn Fn(*mut CKUserIdentity, *mut NSError)>,
        );

        #[cfg(all(feature = "CKRecordID", feature = "CKUserIdentity", feature = "block2"))]
        #[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
        #[method(discoverUserIdentityWithUserRecordID:completionHandler:)]
        pub unsafe fn discoverUserIdentityWithUserRecordID_completionHandler(
            &self,
            user_record_id: &CKRecordID,
            completion_handler: &block2::Block<dyn Fn(*mut CKUserIdentity, *mut NSError)>,
        );
    }
);

extern_methods!(
    /// Sharing
    unsafe impl CKContainer {
        #[cfg(all(feature = "CKShareParticipant", feature = "block2"))]
        #[method(fetchShareParticipantWithEmailAddress:completionHandler:)]
        pub unsafe fn fetchShareParticipantWithEmailAddress_completionHandler(
            &self,
            email_address: &NSString,
            completion_handler: &block2::Block<dyn Fn(*mut CKShareParticipant, *mut NSError)>,
        );

        #[cfg(all(feature = "CKShareParticipant", feature = "block2"))]
        #[method(fetchShareParticipantWithPhoneNumber:completionHandler:)]
        pub unsafe fn fetchShareParticipantWithPhoneNumber_completionHandler(
            &self,
            phone_number: &NSString,
            completion_handler: &block2::Block<dyn Fn(*mut CKShareParticipant, *mut NSError)>,
        );

        #[cfg(all(
            feature = "CKRecordID",
            feature = "CKShareParticipant",
            feature = "block2"
        ))]
        #[method(fetchShareParticipantWithUserRecordID:completionHandler:)]
        pub unsafe fn fetchShareParticipantWithUserRecordID_completionHandler(
            &self,
            user_record_id: &CKRecordID,
            completion_handler: &block2::Block<dyn Fn(*mut CKShareParticipant, *mut NSError)>,
        );

        #[cfg(all(feature = "CKShareMetadata", feature = "block2"))]
        #[method(fetchShareMetadataWithURL:completionHandler:)]
        pub unsafe fn fetchShareMetadataWithURL_completionHandler(
            &self,
            url: &NSURL,
            completion_handler: &block2::Block<dyn Fn(*mut CKShareMetadata, *mut NSError)>,
        );

        #[cfg(all(
            feature = "CKRecord",
            feature = "CKShare",
            feature = "CKShareMetadata",
            feature = "block2"
        ))]
        #[method(acceptShareMetadata:completionHandler:)]
        pub unsafe fn acceptShareMetadata_completionHandler(
            &self,
            metadata: &CKShareMetadata,
            completion_handler: &block2::Block<dyn Fn(*mut CKShare, *mut NSError)>,
        );
    }
);

extern_methods!(
    /// CKLongLivedOperations
    unsafe impl CKContainer {
        #[cfg(all(feature = "CKOperation", feature = "block2"))]
        #[method(fetchAllLongLivedOperationIDsWithCompletionHandler:)]
        pub unsafe fn fetchAllLongLivedOperationIDsWithCompletionHandler(
            &self,
            completion_handler: &block2::Block<dyn Fn(*mut NSArray<CKOperationID>, *mut NSError)>,
        );

        #[cfg(all(feature = "CKOperation", feature = "block2"))]
        #[method(fetchLongLivedOperationWithID:completionHandler:)]
        pub unsafe fn fetchLongLivedOperationWithID_completionHandler(
            &self,
            operation_id: &CKOperationID,
            completion_handler: &block2::Block<dyn Fn(*mut CKOperation, *mut NSError)>,
        );
    }
);