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

/// [Apple's documentation](https://developer.apple.com/documentation/corespotlight/csuserinteraction?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CSUserInteraction(pub NSInteger);
impl CSUserInteraction {
    #[doc(alias = "CSUserInteractionSelect")]
    pub const Select: Self = Self(0);
    #[doc(alias = "CSUserInteractionDefault")]
    pub const Default: Self = Self(CSUserInteraction::Select.0);
    #[doc(alias = "CSUserInteractionFocus")]
    pub const Focus: Self = Self(1);
}

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

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

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

#[cfg(feature = "CSSearchQuery")]
extern_conformance!(
    unsafe impl NSCoding for CSUserQueryContext {}
);

#[cfg(feature = "CSSearchQuery")]
extern_conformance!(
    unsafe impl NSCopying for CSUserQueryContext {}
);

#[cfg(feature = "CSSearchQuery")]
unsafe impl CopyingHelper for CSUserQueryContext {
    type Result = Self;
}

#[cfg(feature = "CSSearchQuery")]
extern_conformance!(
    unsafe impl NSObjectProtocol for CSUserQueryContext {}
);

#[cfg(feature = "CSSearchQuery")]
extern_conformance!(
    unsafe impl NSSecureCoding for CSUserQueryContext {}
);

#[cfg(feature = "CSSearchQuery")]
impl CSUserQueryContext {
    extern_methods!(
        #[unsafe(method(userQueryContext))]
        #[unsafe(method_family = none)]
        pub unsafe fn userQueryContext() -> Retained<CSUserQueryContext>;

        #[cfg(feature = "CSSuggestion")]
        #[unsafe(method(userQueryContextWithCurrentSuggestion:))]
        #[unsafe(method_family = none)]
        pub unsafe fn userQueryContextWithCurrentSuggestion(
            current_suggestion: Option<&CSSuggestion>,
        ) -> Retained<CSUserQueryContext>;

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

        /// Setter for [`enableRankedResults`][Self::enableRankedResults].
        #[unsafe(method(setEnableRankedResults:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setEnableRankedResults(&self, enable_ranked_results: bool);

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

        /// Setter for [`disableSemanticSearch`][Self::disableSemanticSearch].
        #[unsafe(method(setDisableSemanticSearch:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDisableSemanticSearch(&self, disable_semantic_search: bool);

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

        /// Setter for [`maxResultCount`][Self::maxResultCount].
        #[unsafe(method(setMaxResultCount:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setMaxResultCount(&self, max_result_count: NSInteger);

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

        /// Setter for [`maxSuggestionCount`][Self::maxSuggestionCount].
        #[unsafe(method(setMaxSuggestionCount:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setMaxSuggestionCount(&self, max_suggestion_count: NSInteger);

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

        /// Setter for [`maxRankedResultCount`][Self::maxRankedResultCount].
        #[unsafe(method(setMaxRankedResultCount:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setMaxRankedResultCount(&self, max_ranked_result_count: NSInteger);
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "CSSearchQuery")]
impl CSUserQueryContext {
    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/csuserquery?language=objc)
    #[unsafe(super(CSSearchQuery, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "CSSearchQuery")]
    pub struct CSUserQuery;
);

#[cfg(feature = "CSSearchQuery")]
extern_conformance!(
    unsafe impl NSObjectProtocol for CSUserQuery {}
);

#[cfg(feature = "CSSearchQuery")]
impl CSUserQuery {
    extern_methods!(
        #[unsafe(method(prepare))]
        #[unsafe(method_family = none)]
        pub unsafe fn prepare();

        #[unsafe(method(prepareProtectionClasses:))]
        #[unsafe(method_family = none)]
        pub unsafe fn prepareProtectionClasses(protection_classes: &NSArray<NSFileProtectionType>);

        #[unsafe(method(initWithUserQueryString:userQueryContext:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithUserQueryString_userQueryContext(
            this: Allocated<Self>,
            user_query_string: Option<&NSString>,
            user_query_context: Option<&CSUserQueryContext>,
        ) -> Retained<Self>;

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

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

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

        #[cfg(feature = "CSSearchableItem")]
        #[unsafe(method(userEngagedWithItem:visibleItems:userInteractionType:))]
        #[unsafe(method_family = none)]
        pub unsafe fn userEngagedWithItem_visibleItems_userInteractionType(
            &self,
            item: &CSSearchableItem,
            visible_items: &NSArray<CSSearchableItem>,
            user_interaction_type: CSUserInteraction,
        );

        #[cfg(feature = "CSSuggestion")]
        #[unsafe(method(userEngagedWithSuggestion:visibleSuggestions:userInteractionType:))]
        #[unsafe(method_family = none)]
        pub unsafe fn userEngagedWithSuggestion_visibleSuggestions_userInteractionType(
            &self,
            suggestion: &CSSuggestion,
            visible_suggestions: &NSArray<CSSuggestion>,
            user_interaction_type: CSUserInteraction,
        );

        #[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 `CSSearchQuery`.
#[cfg(feature = "CSSearchQuery")]
impl CSUserQuery {
    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>;
    );
}

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