//! 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::*;

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

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

impl CKSystemSharingUIObserver {
    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>;

        #[cfg(feature = "CKContainer")]
        #[unsafe(method(initWithContainer:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithContainer(
            this: Allocated<Self>,
            container: &CKContainer,
        ) -> Retained<Self>;

        #[cfg(all(
            feature = "CKRecord",
            feature = "CKRecordID",
            feature = "CKShare",
            feature = "block2"
        ))]
        /// Called on success or failure of a
        /// `CKShare`save after user modifications via the system sharing UI
        ///
        ///
        /// Following a successful share save by the system sharing UI in the provided
        /// `CKContainer,`this callback will be invoked with a nonnull
        /// `recordID,`a nonnull
        /// `share,`and a nil
        /// `error.`Following a save failure due to a per-item error (
        /// `CKErrorServerRecordChanged,`for example), this callback will be invoked with a nonnull
        /// `recordID,`a nil
        /// `share,`and a nonnull
        /// `error`Each
        /// `CKSystemSharingUIObserver`instance has a private serial queue. This queue is used for all callback block invocations.
        ///
        /// # Safety
        ///
        /// - The returned block's argument 1 must be a valid pointer.
        /// - The returned block's argument 2 must be a valid pointer or null.
        /// - The returned block's argument 3 must be a valid pointer or null.
        #[unsafe(method(systemSharingUIDidSaveShareBlock))]
        #[unsafe(method_family = none)]
        pub unsafe fn systemSharingUIDidSaveShareBlock(
            &self,
        ) -> *mut block2::DynBlock<dyn Fn(NonNull<CKRecordID>, *mut CKShare, *mut NSError)>;

        #[cfg(all(
            feature = "CKRecord",
            feature = "CKRecordID",
            feature = "CKShare",
            feature = "block2"
        ))]
        /// Setter for [`systemSharingUIDidSaveShareBlock`][Self::systemSharingUIDidSaveShareBlock].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setSystemSharingUIDidSaveShareBlock:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setSystemSharingUIDidSaveShareBlock(
            &self,
            system_sharing_ui_did_save_share_block: Option<
                &block2::DynBlock<dyn Fn(NonNull<CKRecordID>, *mut CKShare, *mut NSError)>,
            >,
        );

        #[cfg(all(feature = "CKRecordID", feature = "block2"))]
        /// Called on success or failure of a
        /// `CKShare`delete when the user decides to stop sharing via the system sharing UI
        ///
        ///
        /// Each
        /// `CKSystemSharingUIObserver`instance has a private serial queue. This queue is used for all callback block invocations.
        ///
        /// # Safety
        ///
        /// - The returned block's argument 1 must be a valid pointer.
        /// - The returned block's argument 2 must be a valid pointer or null.
        #[unsafe(method(systemSharingUIDidStopSharingBlock))]
        #[unsafe(method_family = none)]
        pub unsafe fn systemSharingUIDidStopSharingBlock(
            &self,
        ) -> *mut block2::DynBlock<dyn Fn(NonNull<CKRecordID>, *mut NSError)>;

        #[cfg(all(feature = "CKRecordID", feature = "block2"))]
        /// Setter for [`systemSharingUIDidStopSharingBlock`][Self::systemSharingUIDidStopSharingBlock].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setSystemSharingUIDidStopSharingBlock:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setSystemSharingUIDidStopSharingBlock(
            &self,
            system_sharing_ui_did_stop_sharing_block: Option<
                &block2::DynBlock<dyn Fn(NonNull<CKRecordID>, *mut NSError)>,
            >,
        );
    );
}
