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

use crate::*;

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CKRecordSavePolicy(pub NSInteger);
impl CKRecordSavePolicy {
    pub const CKRecordSaveIfServerRecordUnchanged: Self = Self(0);
    pub const CKRecordSaveChangedKeys: Self = Self(1);
    pub const CKRecordSaveAllKeys: Self = Self(2);
}

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

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

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(all(feature = "CKDatabaseOperation", feature = "CKOperation"))]
    pub struct CKModifyRecordsOperation;

    #[cfg(all(feature = "CKDatabaseOperation", feature = "CKOperation"))]
    unsafe impl ClassType for CKModifyRecordsOperation {
        #[inherits(CKOperation, NSOperation, NSObject)]
        type Super = CKDatabaseOperation;
        type Mutability = InteriorMutable;
    }
);

#[cfg(all(feature = "CKDatabaseOperation", feature = "CKOperation"))]
unsafe impl NSObjectProtocol for CKModifyRecordsOperation {}

extern_methods!(
    #[cfg(all(feature = "CKDatabaseOperation", feature = "CKOperation"))]
    unsafe impl CKModifyRecordsOperation {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[cfg(all(feature = "CKRecord", feature = "CKRecordID"))]
        #[method_id(@__retain_semantics Init initWithRecordsToSave:recordIDsToDelete:)]
        pub unsafe fn initWithRecordsToSave_recordIDsToDelete(
            this: Allocated<Self>,
            records: Option<&NSArray<CKRecord>>,
            record_i_ds: Option<&NSArray<CKRecordID>>,
        ) -> Retained<Self>;

        #[cfg(feature = "CKRecord")]
        #[method_id(@__retain_semantics Other recordsToSave)]
        pub unsafe fn recordsToSave(&self) -> Option<Retained<NSArray<CKRecord>>>;

        #[cfg(feature = "CKRecord")]
        #[method(setRecordsToSave:)]
        pub unsafe fn setRecordsToSave(&self, records_to_save: Option<&NSArray<CKRecord>>);

        #[cfg(feature = "CKRecordID")]
        #[method_id(@__retain_semantics Other recordIDsToDelete)]
        pub unsafe fn recordIDsToDelete(&self) -> Option<Retained<NSArray<CKRecordID>>>;

        #[cfg(feature = "CKRecordID")]
        #[method(setRecordIDsToDelete:)]
        pub unsafe fn setRecordIDsToDelete(
            &self,
            record_i_ds_to_delete: Option<&NSArray<CKRecordID>>,
        );

        #[method(savePolicy)]
        pub unsafe fn savePolicy(&self) -> CKRecordSavePolicy;

        #[method(setSavePolicy:)]
        pub unsafe fn setSavePolicy(&self, save_policy: CKRecordSavePolicy);

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

        #[method(setClientChangeTokenData:)]
        pub unsafe fn setClientChangeTokenData(&self, client_change_token_data: Option<&NSData>);

        #[method(atomic)]
        pub unsafe fn atomic(&self) -> bool;

        #[method(setAtomic:)]
        pub unsafe fn setAtomic(&self, atomic: bool);

        #[cfg(all(feature = "CKRecord", feature = "block2"))]
        #[method(perRecordProgressBlock)]
        pub unsafe fn perRecordProgressBlock(
            &self,
        ) -> *mut block2::Block<dyn Fn(NonNull<CKRecord>, c_double)>;

        #[cfg(all(feature = "CKRecord", feature = "block2"))]
        #[method(setPerRecordProgressBlock:)]
        pub unsafe fn setPerRecordProgressBlock(
            &self,
            per_record_progress_block: Option<&block2::Block<dyn Fn(NonNull<CKRecord>, c_double)>>,
        );

        #[cfg(all(feature = "CKRecord", feature = "block2"))]
        #[deprecated]
        #[method(perRecordCompletionBlock)]
        pub unsafe fn perRecordCompletionBlock(
            &self,
        ) -> *mut block2::Block<dyn Fn(NonNull<CKRecord>, *mut NSError)>;

        #[cfg(all(feature = "CKRecord", feature = "block2"))]
        #[deprecated]
        #[method(setPerRecordCompletionBlock:)]
        pub unsafe fn setPerRecordCompletionBlock(
            &self,
            per_record_completion_block: Option<
                &block2::Block<dyn Fn(NonNull<CKRecord>, *mut NSError)>,
            >,
        );

        #[cfg(all(feature = "CKRecord", feature = "CKRecordID", feature = "block2"))]
        #[method(perRecordSaveBlock)]
        pub unsafe fn perRecordSaveBlock(
            &self,
        ) -> *mut block2::Block<dyn Fn(NonNull<CKRecordID>, *mut CKRecord, *mut NSError)>;

        #[cfg(all(feature = "CKRecord", feature = "CKRecordID", feature = "block2"))]
        #[method(setPerRecordSaveBlock:)]
        pub unsafe fn setPerRecordSaveBlock(
            &self,
            per_record_save_block: Option<
                &block2::Block<dyn Fn(NonNull<CKRecordID>, *mut CKRecord, *mut NSError)>,
            >,
        );

        #[cfg(all(feature = "CKRecordID", feature = "block2"))]
        #[method(perRecordDeleteBlock)]
        pub unsafe fn perRecordDeleteBlock(
            &self,
        ) -> *mut block2::Block<dyn Fn(NonNull<CKRecordID>, *mut NSError)>;

        #[cfg(all(feature = "CKRecordID", feature = "block2"))]
        #[method(setPerRecordDeleteBlock:)]
        pub unsafe fn setPerRecordDeleteBlock(
            &self,
            per_record_delete_block: Option<
                &block2::Block<dyn Fn(NonNull<CKRecordID>, *mut NSError)>,
            >,
        );

        #[cfg(all(feature = "CKRecord", feature = "CKRecordID", feature = "block2"))]
        #[method(modifyRecordsCompletionBlock)]
        pub unsafe fn modifyRecordsCompletionBlock(
            &self,
        ) -> *mut block2::Block<
            dyn Fn(*mut NSArray<CKRecord>, *mut NSArray<CKRecordID>, *mut NSError),
        >;

        #[cfg(all(feature = "CKRecord", feature = "CKRecordID", feature = "block2"))]
        #[method(setModifyRecordsCompletionBlock:)]
        pub unsafe fn setModifyRecordsCompletionBlock(
            &self,
            modify_records_completion_block: Option<
                &block2::Block<
                    dyn Fn(*mut NSArray<CKRecord>, *mut NSArray<CKRecordID>, *mut NSError),
                >,
            >,
        );
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    #[cfg(all(feature = "CKDatabaseOperation", feature = "CKOperation"))]
    unsafe impl CKModifyRecordsOperation {
        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Retained<Self>;
    }
);
