objc2-core-spotlight 0.3.2

Bindings to the CoreSpotlight 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::*;
#[cfg(feature = "objc2-uniform-type-identifiers")]
use objc2_uniform_type_identifiers::*;

use crate::*;

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corespotlight/csindexerrordomain?language=objc)
    pub static CSIndexErrorDomain: &'static NSString;
}

/// [Apple's documentation](https://developer.apple.com/documentation/corespotlight/csindexerrorcode?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CSIndexErrorCode(pub NSInteger);
impl CSIndexErrorCode {
    #[doc(alias = "CSIndexErrorCodeUnknownError")]
    pub const UnknownError: Self = Self(-1);
    #[doc(alias = "CSIndexErrorCodeIndexUnavailableError")]
    pub const IndexUnavailableError: Self = Self(-1000);
    #[doc(alias = "CSIndexErrorCodeInvalidItemError")]
    pub const InvalidItemError: Self = Self(-1001);
    #[doc(alias = "CSIndexErrorCodeInvalidClientStateError")]
    pub const InvalidClientStateError: Self = Self(-1002);
    #[doc(alias = "CSIndexErrorCodeRemoteConnectionError")]
    pub const RemoteConnectionError: Self = Self(-1003);
    #[doc(alias = "CSIndexErrorCodeQuotaExceeded")]
    pub const QuotaExceeded: Self = Self(-1004);
    #[doc(alias = "CSIndexErrorCodeIndexingUnsupported")]
    pub const IndexingUnsupported: Self = Self(-1005);
    #[doc(alias = "CSIndexErrorCodeMismatchedClientState")]
    pub const MismatchedClientState: Self = Self(-1006);
}

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

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

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

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

impl CSSearchableIndex {
    extern_methods!(
        #[unsafe(method(indexDelegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn indexDelegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn CSSearchableIndexDelegate>>>;

        /// Setter for [`indexDelegate`][Self::indexDelegate].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        #[unsafe(method(setIndexDelegate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setIndexDelegate(
            &self,
            index_delegate: Option<&ProtocolObject<dyn CSSearchableIndexDelegate>>,
        );

        #[unsafe(method(isIndexingAvailable))]
        #[unsafe(method_family = none)]
        pub unsafe fn isIndexingAvailable() -> bool;

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

        #[unsafe(method(initWithName:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithName(this: Allocated<Self>, name: &NSString) -> Retained<Self>;

        #[unsafe(method(initWithName:protectionClass:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithName_protectionClass(
            this: Allocated<Self>,
            name: &NSString,
            protection_class: Option<&NSFileProtectionType>,
        ) -> Retained<Self>;

        #[cfg(all(feature = "CSSearchableItem", feature = "block2"))]
        #[unsafe(method(indexSearchableItems:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn indexSearchableItems_completionHandler(
            &self,
            items: &NSArray<CSSearchableItem>,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
        );

        #[cfg(feature = "block2")]
        #[unsafe(method(deleteSearchableItemsWithIdentifiers:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn deleteSearchableItemsWithIdentifiers_completionHandler(
            &self,
            identifiers: &NSArray<NSString>,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
        );

        #[cfg(feature = "block2")]
        #[unsafe(method(deleteSearchableItemsWithDomainIdentifiers:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn deleteSearchableItemsWithDomainIdentifiers_completionHandler(
            &self,
            domain_identifiers: &NSArray<NSString>,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
        );

        #[cfg(feature = "block2")]
        #[unsafe(method(deleteAllSearchableItemsWithCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn deleteAllSearchableItemsWithCompletionHandler(
            &self,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
        );
    );
}

/// Methods declared on superclass `NSObject`.
impl CSSearchableIndex {
    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>;
    );
}

/// CSOptionalBatching.
impl CSSearchableIndex {
    extern_methods!(
        #[unsafe(method(beginIndexBatch))]
        #[unsafe(method_family = none)]
        pub unsafe fn beginIndexBatch(&self);

        #[cfg(feature = "block2")]
        #[unsafe(method(endIndexBatchWithExpectedClientState:newClientState:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn endIndexBatchWithExpectedClientState_newClientState_completionHandler(
            &self,
            expected_client_state: Option<&NSData>,
            new_client_state: &NSData,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
        );

        #[cfg(feature = "block2")]
        #[unsafe(method(endIndexBatchWithClientState:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn endIndexBatchWithClientState_completionHandler(
            &self,
            client_state: &NSData,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
        );

        #[cfg(feature = "block2")]
        #[unsafe(method(fetchLastClientStateWithCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn fetchLastClientStateWithCompletionHandler(
            &self,
            completion_handler: &block2::DynBlock<dyn Fn(*mut NSData, *mut NSError)>,
        );
    );
}

/// CSExternalProvider.
impl CSSearchableIndex {
    extern_methods!(
        #[cfg(all(feature = "block2", feature = "objc2-uniform-type-identifiers"))]
        #[unsafe(method(fetchDataForBundleIdentifier:itemIdentifier:contentType:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn fetchDataForBundleIdentifier_itemIdentifier_contentType_completionHandler(
            &self,
            bundle_identifier: &NSString,
            item_identifier: &NSString,
            content_type: &UTType,
            completion_handler: &block2::DynBlock<dyn Fn(*mut NSData, *mut NSError)>,
        );
    );
}

/// CSOptionalBatchingWithExpectedState.
impl CSSearchableIndex {
    extern_methods!();
}

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/corespotlight/cssearchableindexdelegate?language=objc)
    pub unsafe trait CSSearchableIndexDelegate: NSObjectProtocol {
        #[cfg(feature = "block2")]
        #[unsafe(method(searchableIndex:reindexAllSearchableItemsWithAcknowledgementHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn searchableIndex_reindexAllSearchableItemsWithAcknowledgementHandler(
            &self,
            searchable_index: &CSSearchableIndex,
            acknowledgement_handler: &block2::DynBlock<dyn Fn()>,
        );

        #[cfg(feature = "block2")]
        #[unsafe(method(searchableIndex:reindexSearchableItemsWithIdentifiers:acknowledgementHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn searchableIndex_reindexSearchableItemsWithIdentifiers_acknowledgementHandler(
            &self,
            searchable_index: &CSSearchableIndex,
            identifiers: &NSArray<NSString>,
            acknowledgement_handler: &block2::DynBlock<dyn Fn()>,
        );

        #[optional]
        #[unsafe(method(searchableIndexDidThrottle:))]
        #[unsafe(method_family = none)]
        unsafe fn searchableIndexDidThrottle(&self, searchable_index: &CSSearchableIndex);

        #[optional]
        #[unsafe(method(searchableIndexDidFinishThrottle:))]
        #[unsafe(method_family = none)]
        unsafe fn searchableIndexDidFinishThrottle(&self, searchable_index: &CSSearchableIndex);

        #[optional]
        #[unsafe(method(dataForSearchableIndex:itemIdentifier:typeIdentifier:error:_))]
        #[unsafe(method_family = none)]
        unsafe fn dataForSearchableIndex_itemIdentifier_typeIdentifier_error(
            &self,
            searchable_index: &CSSearchableIndex,
            item_identifier: &NSString,
            type_identifier: &NSString,
        ) -> Result<Retained<NSData>, Retained<NSError>>;

        #[optional]
        #[unsafe(method(fileURLForSearchableIndex:itemIdentifier:typeIdentifier:inPlace:error:_))]
        #[unsafe(method_family = none)]
        unsafe fn fileURLForSearchableIndex_itemIdentifier_typeIdentifier_inPlace_error(
            &self,
            searchable_index: &CSSearchableIndex,
            item_identifier: &NSString,
            type_identifier: &NSString,
            in_place: bool,
        ) -> Result<Retained<NSURL>, Retained<NSError>>;

        #[cfg(all(feature = "CSSearchableItem", feature = "block2"))]
        #[optional]
        #[unsafe(method(searchableItemsForIdentifiers:searchableItemsHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn searchableItemsForIdentifiers_searchableItemsHandler(
            &self,
            identifiers: &NSArray<NSString>,
            searchable_items_handler: &block2::DynBlock<dyn Fn(NonNull<NSArray<CSSearchableItem>>)>,
        );

        #[cfg(feature = "CSSearchableItem")]
        #[optional]
        #[unsafe(method(searchableItemsDidUpdate:))]
        #[unsafe(method_family = none)]
        unsafe fn searchableItemsDidUpdate(&self, items: &NSArray<CSSearchableItem>);
    }
);