objc2-file-provider 0.3.2

Bindings to the FileProvider 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_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidersearchresult?language=objc)
    pub unsafe trait NSFileProviderSearchResult {
        #[cfg(feature = "NSFileProviderItem")]
        /// The identifier for this search result.
        /// This identifier should be usable on API calls from the
        /// ``NSFileProviderReplicatedExtension`` protocol.
        #[unsafe(method(itemIdentifier))]
        #[unsafe(method_family = none)]
        unsafe fn itemIdentifier(&self) -> Retained<NSFileProviderItemIdentifier>;

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

        #[unsafe(method(creationDate))]
        #[unsafe(method_family = none)]
        unsafe fn creationDate(&self) -> Option<Retained<NSDate>>;

        #[unsafe(method(contentModificationDate))]
        #[unsafe(method_family = none)]
        unsafe fn contentModificationDate(&self) -> Option<Retained<NSDate>>;

        #[unsafe(method(lastUsedDate))]
        #[unsafe(method_family = none)]
        unsafe fn lastUsedDate(&self) -> Option<Retained<NSDate>>;

        #[cfg(feature = "objc2-uniform-type-identifiers")]
        #[unsafe(method(contentType))]
        #[unsafe(method_family = none)]
        unsafe fn contentType(&self) -> Retained<UTType>;

        #[unsafe(method(documentSize))]
        #[unsafe(method_family = none)]
        unsafe fn documentSize(&self) -> Option<Retained<NSNumber>>;
    }
);

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidersearchenumerationobserver?language=objc)
    pub unsafe trait NSFileProviderSearchEnumerationObserver: NSObjectProtocol {
        #[unsafe(method(didEnumerateSearchResults:))]
        #[unsafe(method_family = none)]
        unsafe fn didEnumerateSearchResults(
            &self,
            search_results: &NSArray<ProtocolObject<dyn NSFileProviderSearchResult>>,
        );

        #[cfg(feature = "NSFileProviderEnumerating")]
        /// Call this method after enumerating a full page of results.  If you set a non-nil
        /// nextPage, -[NSFileProviderSearchEnumerator enumerateSearchResultsToObserver:startingAtPage:]
        /// might be called with nextPage to enumerate more items.
        ///
        /// Page data is limited to 500 bytes.  Setting a larger nextPage interrupts the
        /// enumeration.
        #[unsafe(method(finishEnumeratingUpToPage:))]
        #[unsafe(method_family = none)]
        unsafe fn finishEnumeratingUpToPage(&self, next_page: Option<&NSFileProviderPage>);

        /// Finishing a search enumeration with an error will cause the system to stop
        /// requesting additional pages of results.
        /// The system will not retry in case of an error. It is up to the extension
        /// to decide whether to retry errors internally, in their implementation of `enumerateSearchResultsForObserver`,
        /// or to return the error to the system and end the search query.
        #[unsafe(method(finishEnumeratingWithError:))]
        #[unsafe(method_family = none)]
        unsafe fn finishEnumeratingWithError(&self, error: &NSError);

        /// The maximum number of results to return in a single page enumeration.
        ///
        /// If the extension returns more than this number of results in a single page enumeration,
        /// the system will crash the extension process.
        #[unsafe(method(maximumNumberOfResultsPerPage))]
        #[unsafe(method_family = none)]
        unsafe fn maximumNumberOfResultsPerPage(&self) -> NSInteger;
    }
);

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidersearchenumerator?language=objc)
    pub unsafe trait NSFileProviderSearchEnumerator: NSObjectProtocol {
        /// Called when the system wants to cancel a currently running enumeration, or when the system is finished using this enumerator object.
        ///
        /// For instance, the user has changed their query, and the result of the currently running query will no longer
        /// be used by the system.
        ///
        /// Or, the system is finished using this enumerator object.
        ///
        /// The extension should cancel any outstanding requests and cleanup resources.
        #[unsafe(method(invalidate))]
        #[unsafe(method_family = none)]
        unsafe fn invalidate(&self);

        #[cfg(feature = "NSFileProviderEnumerating")]
        /// Enumerate search results starting from the specified page.
        ///
        /// - Parameters:
        /// - observer: The observer object, which the extension will use to provide results.
        /// - page: If a previous enumeration returned a `nextPage` on
        /// ``-[NSFileProviderSearchEnumerationObserver finishEnumeratingUpToPage:]``,
        /// the system may pass that page into the next enumeration.
        /// The page should contain whatever information is needed to resume the enumeration.
        #[unsafe(method(enumerateSearchResultsForObserver:startingAtPage:))]
        #[unsafe(method_family = none)]
        unsafe fn enumerateSearchResultsForObserver_startingAtPage(
            &self,
            observer: &ProtocolObject<dyn NSFileProviderSearchEnumerationObserver>,
            page: Option<&NSFileProviderPage>,
        );
    }
);

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

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

impl NSFileProviderStringSearchRequest {
    extern_methods!(
        /// A plaintext string, representing the query the user entered into the system search UI.
        #[unsafe(method(query))]
        #[unsafe(method_family = none)]
        pub unsafe fn query(&self) -> Retained<NSString>;

        /// How many results the system is requesting. This is a hint to the extension, to help avoid
        /// unnecessary work. The extension may return more results than this.
        #[unsafe(method(desiredNumberOfResults))]
        #[unsafe(method_family = none)]
        pub unsafe fn desiredNumberOfResults(&self) -> NSInteger;
    );
}

/// Methods declared on superclass `NSObject`.
impl NSFileProviderStringSearchRequest {
    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_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidersearching?language=objc)
    pub unsafe trait NSFileProviderSearching: NSObjectProtocol {
        /// Called by the system to retrieve search results for a user search query.
        #[unsafe(method(searchEnumeratorForStringSearchRequest:))]
        #[unsafe(method_family = none)]
        unsafe fn searchEnumeratorForStringSearchRequest(
            &self,
            request: &NSFileProviderStringSearchRequest,
        ) -> Retained<ProtocolObject<dyn NSFileProviderSearchEnumerator>>;
    }
);