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

use crate::*;

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

/// [Apple's documentation](https://developer.apple.com/documentation/corespotlight/cssearchqueryerrorcode?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CSSearchQueryErrorCode(pub NSInteger);
impl CSSearchQueryErrorCode {
    #[doc(alias = "CSSearchQueryErrorCodeUnknown")]
    pub const Unknown: Self = Self(-2000);
    #[doc(alias = "CSSearchQueryErrorCodeIndexUnreachable")]
    pub const IndexUnreachable: Self = Self(-2001);
    #[doc(alias = "CSSearchQueryErrorCodeInvalidQuery")]
    pub const InvalidQuery: Self = Self(-2002);
    #[doc(alias = "CSSearchQueryErrorCodeCancelled")]
    pub const Cancelled: Self = Self(-2003);
}

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

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

/// [Apple's documentation](https://developer.apple.com/documentation/corespotlight/cssearchquerysourceoptions?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CSSearchQuerySourceOptions(pub NSUInteger);
bitflags::bitflags! {
    impl CSSearchQuerySourceOptions: NSUInteger {
        #[doc(alias = "CSSearchQuerySourceOptionDefault")]
        const Default = 0;
        #[doc(alias = "CSSearchQuerySourceOptionAllowMail")]
        const AllowMail = 1<<0;
    }
}

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

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

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

extern_conformance!(
    unsafe impl NSCoding for CSSearchQueryContext {}
);

extern_conformance!(
    unsafe impl NSCopying for CSSearchQueryContext {}
);

unsafe impl CopyingHelper for CSSearchQueryContext {
    type Result = Self;
}

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

extern_conformance!(
    unsafe impl NSSecureCoding for CSSearchQueryContext {}
);

impl CSSearchQueryContext {
    extern_methods!(
        #[unsafe(method(fetchAttributes))]
        #[unsafe(method_family = none)]
        pub unsafe fn fetchAttributes(&self) -> Retained<NSArray<NSString>>;

        /// Setter for [`fetchAttributes`][Self::fetchAttributes].
        #[unsafe(method(setFetchAttributes:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setFetchAttributes(&self, fetch_attributes: &NSArray<NSString>);

        #[unsafe(method(filterQueries))]
        #[unsafe(method_family = none)]
        pub unsafe fn filterQueries(&self) -> Retained<NSArray<NSString>>;

        /// Setter for [`filterQueries`][Self::filterQueries].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setFilterQueries:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setFilterQueries(&self, filter_queries: &NSArray<NSString>);

        #[unsafe(method(keyboardLanguage))]
        #[unsafe(method_family = none)]
        pub unsafe fn keyboardLanguage(&self) -> Option<Retained<NSString>>;

        /// Setter for [`keyboardLanguage`][Self::keyboardLanguage].
        #[unsafe(method(setKeyboardLanguage:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setKeyboardLanguage(&self, keyboard_language: Option<&NSString>);

        #[unsafe(method(sourceOptions))]
        #[unsafe(method_family = none)]
        pub unsafe fn sourceOptions(&self) -> CSSearchQuerySourceOptions;

        /// Setter for [`sourceOptions`][Self::sourceOptions].
        #[unsafe(method(setSourceOptions:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setSourceOptions(&self, source_options: CSSearchQuerySourceOptions);
    );
}

/// Methods declared on superclass `NSObject`.
impl CSSearchQueryContext {
    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_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/corespotlight/cssearchquery?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct CSSearchQuery;
);

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

impl CSSearchQuery {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(initWithQueryString:queryContext:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithQueryString_queryContext(
            this: Allocated<Self>,
            query_string: &NSString,
            query_context: Option<&CSSearchQueryContext>,
        ) -> Retained<Self>;

        #[deprecated = "Use initWithQueryString:queryContext instead"]
        #[unsafe(method(initWithQueryString:attributes:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithQueryString_attributes(
            this: Allocated<Self>,
            query_string: &NSString,
            attributes: Option<&NSArray<NSString>>,
        ) -> Retained<Self>;

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

        #[unsafe(method(foundItemCount))]
        #[unsafe(method_family = none)]
        pub unsafe fn foundItemCount(&self) -> NSUInteger;

        #[cfg(all(feature = "CSSearchableItem", feature = "block2"))]
        /// # Safety
        ///
        /// The returned block's argument must be a valid pointer.
        #[unsafe(method(foundItemsHandler))]
        #[unsafe(method_family = none)]
        pub unsafe fn foundItemsHandler(
            &self,
        ) -> *mut block2::DynBlock<dyn Fn(NonNull<NSArray<CSSearchableItem>>)>;

        #[cfg(all(feature = "CSSearchableItem", feature = "block2"))]
        /// Setter for [`foundItemsHandler`][Self::foundItemsHandler].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setFoundItemsHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setFoundItemsHandler(
            &self,
            found_items_handler: Option<
                &block2::DynBlock<dyn Fn(NonNull<NSArray<CSSearchableItem>>)>,
            >,
        );

        #[cfg(feature = "block2")]
        /// # Safety
        ///
        /// The returned block's argument must be a valid pointer or null.
        #[unsafe(method(completionHandler))]
        #[unsafe(method_family = none)]
        pub unsafe fn completionHandler(&self) -> *mut block2::DynBlock<dyn Fn(*mut NSError)>;

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

        #[unsafe(method(protectionClasses))]
        #[unsafe(method_family = none)]
        pub unsafe fn protectionClasses(&self) -> Retained<NSArray<NSFileProtectionType>>;

        /// Setter for [`protectionClasses`][Self::protectionClasses].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setProtectionClasses:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setProtectionClasses(
            &self,
            protection_classes: &NSArray<NSFileProtectionType>,
        );

        #[unsafe(method(start))]
        #[unsafe(method_family = none)]
        pub unsafe fn start(&self);

        #[unsafe(method(cancel))]
        #[unsafe(method_family = none)]
        pub unsafe fn cancel(&self);
    );
}

/// Methods declared on superclass `NSObject`.
impl CSSearchQuery {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}