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

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

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

impl NSMetadataQuery {
    extern_methods!(
        /// # Safety
        ///
        /// This is not retained internally, you must ensure the object is still alive.
        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn delegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn NSMetadataQueryDelegate>>>;

        /// Setter for [`delegate`][Self::delegate].
        ///
        /// # Safety
        ///
        /// This is unretained, you must ensure the object is kept alive while in use.
        #[unsafe(method(setDelegate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDelegate(
            &self,
            delegate: Option<&ProtocolObject<dyn NSMetadataQueryDelegate>>,
        );

        #[cfg(feature = "NSPredicate")]
        #[unsafe(method(predicate))]
        #[unsafe(method_family = none)]
        pub fn predicate(&self) -> Option<Retained<NSPredicate>>;

        #[cfg(feature = "NSPredicate")]
        /// Setter for [`predicate`][Self::predicate].
        ///
        /// This is [copied][crate::NSCopying::copy] when set.
        #[unsafe(method(setPredicate:))]
        #[unsafe(method_family = none)]
        pub fn setPredicate(&self, predicate: Option<&NSPredicate>);

        #[cfg(all(feature = "NSArray", feature = "NSSortDescriptor"))]
        #[unsafe(method(sortDescriptors))]
        #[unsafe(method_family = none)]
        pub fn sortDescriptors(&self) -> Retained<NSArray<NSSortDescriptor>>;

        #[cfg(all(feature = "NSArray", feature = "NSSortDescriptor"))]
        /// Setter for [`sortDescriptors`][Self::sortDescriptors].
        ///
        /// This is [copied][crate::NSCopying::copy] when set.
        #[unsafe(method(setSortDescriptors:))]
        #[unsafe(method_family = none)]
        pub fn setSortDescriptors(&self, sort_descriptors: &NSArray<NSSortDescriptor>);

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[unsafe(method(valueListAttributes))]
        #[unsafe(method_family = none)]
        pub fn valueListAttributes(&self) -> Retained<NSArray<NSString>>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        /// Setter for [`valueListAttributes`][Self::valueListAttributes].
        ///
        /// This is [copied][crate::NSCopying::copy] when set.
        #[unsafe(method(setValueListAttributes:))]
        #[unsafe(method_family = none)]
        pub fn setValueListAttributes(&self, value_list_attributes: &NSArray<NSString>);

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[unsafe(method(groupingAttributes))]
        #[unsafe(method_family = none)]
        pub fn groupingAttributes(&self) -> Option<Retained<NSArray<NSString>>>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        /// Setter for [`groupingAttributes`][Self::groupingAttributes].
        ///
        /// This is [copied][crate::NSCopying::copy] when set.
        #[unsafe(method(setGroupingAttributes:))]
        #[unsafe(method_family = none)]
        pub fn setGroupingAttributes(&self, grouping_attributes: Option<&NSArray<NSString>>);

        #[cfg(feature = "NSDate")]
        #[unsafe(method(notificationBatchingInterval))]
        #[unsafe(method_family = none)]
        pub fn notificationBatchingInterval(&self) -> NSTimeInterval;

        #[cfg(feature = "NSDate")]
        /// Setter for [`notificationBatchingInterval`][Self::notificationBatchingInterval].
        #[unsafe(method(setNotificationBatchingInterval:))]
        #[unsafe(method_family = none)]
        pub fn setNotificationBatchingInterval(
            &self,
            notification_batching_interval: NSTimeInterval,
        );

        #[cfg(feature = "NSArray")]
        #[unsafe(method(searchScopes))]
        #[unsafe(method_family = none)]
        pub fn searchScopes(&self) -> Retained<NSArray>;

        #[cfg(feature = "NSArray")]
        /// Setter for [`searchScopes`][Self::searchScopes].
        ///
        /// This is [copied][crate::NSCopying::copy] when set.
        ///
        /// # Safety
        ///
        /// `search_scopes` generic should be of the correct type.
        #[unsafe(method(setSearchScopes:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setSearchScopes(&self, search_scopes: &NSArray);

        #[cfg(feature = "NSArray")]
        #[unsafe(method(searchItems))]
        #[unsafe(method_family = none)]
        pub fn searchItems(&self) -> Option<Retained<NSArray>>;

        #[cfg(feature = "NSArray")]
        /// Setter for [`searchItems`][Self::searchItems].
        ///
        /// This is [copied][crate::NSCopying::copy] when set.
        ///
        /// # Safety
        ///
        /// `search_items` generic should be of the correct type.
        #[unsafe(method(setSearchItems:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setSearchItems(&self, search_items: Option<&NSArray>);

        #[cfg(feature = "NSOperation")]
        #[unsafe(method(operationQueue))]
        #[unsafe(method_family = none)]
        pub fn operationQueue(&self) -> Option<Retained<NSOperationQueue>>;

        #[cfg(feature = "NSOperation")]
        /// Setter for [`operationQueue`][Self::operationQueue].
        ///
        /// # Safety
        ///
        /// `operation_queue` possibly has additional threading requirements.
        #[unsafe(method(setOperationQueue:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setOperationQueue(&self, operation_queue: Option<&NSOperationQueue>);

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

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

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

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

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

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

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

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

        #[unsafe(method(resultAtIndex:))]
        #[unsafe(method_family = none)]
        pub fn resultAtIndex(&self, idx: NSUInteger) -> Retained<AnyObject>;

        #[cfg(feature = "block2")]
        #[unsafe(method(enumerateResultsUsingBlock:))]
        #[unsafe(method_family = none)]
        pub fn enumerateResultsUsingBlock(
            &self,
            block: &block2::DynBlock<dyn Fn(NonNull<AnyObject>, NSUInteger, NonNull<Bool>) + '_>,
        );

        #[cfg(all(feature = "NSObjCRuntime", feature = "block2"))]
        #[unsafe(method(enumerateResultsWithOptions:usingBlock:))]
        #[unsafe(method_family = none)]
        pub fn enumerateResultsWithOptions_usingBlock(
            &self,
            opts: NSEnumerationOptions,
            block: &block2::DynBlock<dyn Fn(NonNull<AnyObject>, NSUInteger, NonNull<Bool>) + '_>,
        );

        #[cfg(feature = "NSArray")]
        #[unsafe(method(results))]
        #[unsafe(method_family = none)]
        pub fn results(&self) -> Retained<NSArray>;

        /// # Safety
        ///
        /// `result` should be of the correct type.
        #[unsafe(method(indexOfResult:))]
        #[unsafe(method_family = none)]
        pub unsafe fn indexOfResult(&self, result: &AnyObject) -> NSUInteger;

        #[cfg(all(feature = "NSArray", feature = "NSDictionary", feature = "NSString"))]
        #[unsafe(method(valueLists))]
        #[unsafe(method_family = none)]
        pub fn valueLists(
            &self,
        ) -> Retained<NSDictionary<NSString, NSArray<NSMetadataQueryAttributeValueTuple>>>;

        #[cfg(feature = "NSArray")]
        #[unsafe(method(groupedResults))]
        #[unsafe(method_family = none)]
        pub fn groupedResults(&self) -> Retained<NSArray<NSMetadataQueryResultGroup>>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(valueOfAttribute:forResultAtIndex:))]
        #[unsafe(method_family = none)]
        pub fn valueOfAttribute_forResultAtIndex(
            &self,
            attr_name: &NSString,
            idx: NSUInteger,
        ) -> Option<Retained<AnyObject>>;
    );
}

/// Methods declared on superclass `NSObject`.
impl NSMetadataQuery {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;

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

impl DefaultRetained for NSMetadataQuery {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataquerydelegate?language=objc)
    pub unsafe trait NSMetadataQueryDelegate: NSObjectProtocol {
        #[optional]
        #[unsafe(method(metadataQuery:replacementObjectForResultObject:))]
        #[unsafe(method_family = none)]
        fn metadataQuery_replacementObjectForResultObject(
            &self,
            query: &NSMetadataQuery,
            result: &NSMetadataItem,
        ) -> Retained<AnyObject>;

        #[cfg(feature = "NSString")]
        /// # Safety
        ///
        /// `attr_value` should be of the correct type.
        #[optional]
        #[unsafe(method(metadataQuery:replacementValueForAttribute:value:))]
        #[unsafe(method_family = none)]
        unsafe fn metadataQuery_replacementValueForAttribute_value(
            &self,
            query: &NSMetadataQuery,
            attr_name: &NSString,
            attr_value: &AnyObject,
        ) -> Retained<AnyObject>;
    }
);

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataquerydidstartgatheringnotification?language=objc)
    #[cfg(all(feature = "NSNotification", feature = "NSString"))]
    pub static NSMetadataQueryDidStartGatheringNotification: &'static NSNotificationName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataquerygatheringprogressnotification?language=objc)
    #[cfg(all(feature = "NSNotification", feature = "NSString"))]
    pub static NSMetadataQueryGatheringProgressNotification: &'static NSNotificationName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataquerydidfinishgatheringnotification?language=objc)
    #[cfg(all(feature = "NSNotification", feature = "NSString"))]
    pub static NSMetadataQueryDidFinishGatheringNotification: &'static NSNotificationName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataquerydidupdatenotification?language=objc)
    #[cfg(all(feature = "NSNotification", feature = "NSString"))]
    pub static NSMetadataQueryDidUpdateNotification: &'static NSNotificationName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataqueryupdateaddeditemskey?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSMetadataQueryUpdateAddedItemsKey: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataqueryupdatechangeditemskey?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSMetadataQueryUpdateChangedItemsKey: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataqueryupdateremoveditemskey?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSMetadataQueryUpdateRemovedItemsKey: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataqueryresultcontentrelevanceattribute?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSMetadataQueryResultContentRelevanceAttribute: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataqueryuserhomescope?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSMetadataQueryUserHomeScope: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataquerylocalcomputerscope?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSMetadataQueryLocalComputerScope: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataquerynetworkscope?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSMetadataQueryNetworkScope: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataqueryindexedlocalcomputerscope?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSMetadataQueryIndexedLocalComputerScope: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataqueryindexednetworkscope?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSMetadataQueryIndexedNetworkScope: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataqueryubiquitousdocumentsscope?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSMetadataQueryUbiquitousDocumentsScope: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataqueryubiquitousdatascope?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSMetadataQueryUbiquitousDataScope: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataqueryaccessibleubiquitousexternaldocumentsscope?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSMetadataQueryAccessibleUbiquitousExternalDocumentsScope: &'static NSString;
}

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

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

impl NSMetadataItem {
    extern_methods!(
        #[cfg(feature = "NSURL")]
        #[unsafe(method(initWithURL:))]
        #[unsafe(method_family = init)]
        pub fn initWithURL(this: Allocated<Self>, url: &NSURL) -> Option<Retained<Self>>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(valueForAttribute:))]
        #[unsafe(method_family = none)]
        pub fn valueForAttribute(&self, key: &NSString) -> Option<Retained<AnyObject>>;

        #[cfg(all(feature = "NSArray", feature = "NSDictionary", feature = "NSString"))]
        #[unsafe(method(valuesForAttributes:))]
        #[unsafe(method_family = none)]
        pub fn valuesForAttributes(
            &self,
            keys: &NSArray<NSString>,
        ) -> Option<Retained<NSDictionary<NSString, AnyObject>>>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[unsafe(method(attributes))]
        #[unsafe(method_family = none)]
        pub fn attributes(&self) -> Retained<NSArray<NSString>>;
    );
}

/// Methods declared on superclass `NSObject`.
impl NSMetadataItem {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;

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

impl DefaultRetained for NSMetadataItem {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}

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

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

impl NSMetadataQueryAttributeValueTuple {
    extern_methods!(
        #[cfg(feature = "NSString")]
        #[unsafe(method(attribute))]
        #[unsafe(method_family = none)]
        pub fn attribute(&self) -> Retained<NSString>;

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

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

/// Methods declared on superclass `NSObject`.
impl NSMetadataQueryAttributeValueTuple {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;

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

impl DefaultRetained for NSMetadataQueryAttributeValueTuple {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}

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

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

impl NSMetadataQueryResultGroup {
    extern_methods!(
        #[cfg(feature = "NSString")]
        #[unsafe(method(attribute))]
        #[unsafe(method_family = none)]
        pub fn attribute(&self) -> Retained<NSString>;

        #[unsafe(method(value))]
        #[unsafe(method_family = none)]
        pub fn value(&self) -> Retained<AnyObject>;

        #[cfg(feature = "NSArray")]
        #[unsafe(method(subgroups))]
        #[unsafe(method_family = none)]
        pub fn subgroups(&self) -> Option<Retained<NSArray<NSMetadataQueryResultGroup>>>;

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

        #[unsafe(method(resultAtIndex:))]
        #[unsafe(method_family = none)]
        pub fn resultAtIndex(&self, idx: NSUInteger) -> Retained<AnyObject>;

        #[cfg(feature = "NSArray")]
        #[unsafe(method(results))]
        #[unsafe(method_family = none)]
        pub fn results(&self) -> Retained<NSArray>;
    );
}

/// Methods declared on superclass `NSObject`.
impl NSMetadataQueryResultGroup {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;

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

impl DefaultRetained for NSMetadataQueryResultGroup {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}
