objc2_file_provider/generated/
NSFileProviderSearch.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7#[cfg(feature = "objc2-uniform-type-identifiers")]
8use objc2_uniform_type_identifiers::*;
9
10use crate::*;
11
12extern_protocol!(
13    /// [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidersearchresult?language=objc)
14    pub unsafe trait NSFileProviderSearchResult {
15        #[cfg(feature = "NSFileProviderItem")]
16        /// The identifier for this search result.
17        /// This identifier should be usable on API calls from the
18        /// ``NSFileProviderReplicatedExtension`` protocol.
19        #[unsafe(method(itemIdentifier))]
20        #[unsafe(method_family = none)]
21        unsafe fn itemIdentifier(&self) -> Retained<NSFileProviderItemIdentifier>;
22
23        #[unsafe(method(filename))]
24        #[unsafe(method_family = none)]
25        unsafe fn filename(&self) -> Retained<NSString>;
26
27        #[unsafe(method(creationDate))]
28        #[unsafe(method_family = none)]
29        unsafe fn creationDate(&self) -> Option<Retained<NSDate>>;
30
31        #[unsafe(method(contentModificationDate))]
32        #[unsafe(method_family = none)]
33        unsafe fn contentModificationDate(&self) -> Option<Retained<NSDate>>;
34
35        #[unsafe(method(lastUsedDate))]
36        #[unsafe(method_family = none)]
37        unsafe fn lastUsedDate(&self) -> Option<Retained<NSDate>>;
38
39        #[cfg(feature = "objc2-uniform-type-identifiers")]
40        #[unsafe(method(contentType))]
41        #[unsafe(method_family = none)]
42        unsafe fn contentType(&self) -> Retained<UTType>;
43
44        #[unsafe(method(documentSize))]
45        #[unsafe(method_family = none)]
46        unsafe fn documentSize(&self) -> Option<Retained<NSNumber>>;
47    }
48);
49
50extern_protocol!(
51    /// [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidersearchenumerationobserver?language=objc)
52    pub unsafe trait NSFileProviderSearchEnumerationObserver: NSObjectProtocol {
53        #[unsafe(method(didEnumerateSearchResults:))]
54        #[unsafe(method_family = none)]
55        unsafe fn didEnumerateSearchResults(
56            &self,
57            search_results: &NSArray<ProtocolObject<dyn NSFileProviderSearchResult>>,
58        );
59
60        #[cfg(feature = "NSFileProviderEnumerating")]
61        /// Call this method after enumerating a full page of results.  If you set a non-nil
62        /// nextPage, -[NSFileProviderSearchEnumerator enumerateSearchResultsToObserver:startingAtPage:]
63        /// might be called with nextPage to enumerate more items.
64        ///
65        /// Page data is limited to 500 bytes.  Setting a larger nextPage interrupts the
66        /// enumeration.
67        #[unsafe(method(finishEnumeratingUpToPage:))]
68        #[unsafe(method_family = none)]
69        unsafe fn finishEnumeratingUpToPage(&self, next_page: Option<&NSFileProviderPage>);
70
71        /// Finishing a search enumeration with an error will cause the system to stop
72        /// requesting additional pages of results.
73        /// The system will not retry in case of an error. It is up to the extension
74        /// to decide whether to retry errors internally, in their implementation of `enumerateSearchResultsForObserver`,
75        /// or to return the error to the system and end the search query.
76        #[unsafe(method(finishEnumeratingWithError:))]
77        #[unsafe(method_family = none)]
78        unsafe fn finishEnumeratingWithError(&self, error: &NSError);
79
80        /// The maximum number of results to return in a single page enumeration.
81        ///
82        /// If the extension returns more than this number of results in a single page enumeration,
83        /// the system will crash the extension process.
84        #[unsafe(method(maximumNumberOfResultsPerPage))]
85        #[unsafe(method_family = none)]
86        unsafe fn maximumNumberOfResultsPerPage(&self) -> NSInteger;
87    }
88);
89
90extern_protocol!(
91    /// [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidersearchenumerator?language=objc)
92    pub unsafe trait NSFileProviderSearchEnumerator: NSObjectProtocol {
93        /// Called when the system wants to cancel a currently running enumeration, or when the system is finished using this enumerator object.
94        ///
95        /// For instance, the user has changed their query, and the result of the currently running query will no longer
96        /// be used by the system.
97        ///
98        /// Or, the system is finished using this enumerator object.
99        ///
100        /// The extension should cancel any outstanding requests and cleanup resources.
101        #[unsafe(method(invalidate))]
102        #[unsafe(method_family = none)]
103        unsafe fn invalidate(&self);
104
105        #[cfg(feature = "NSFileProviderEnumerating")]
106        /// Enumerate search results starting from the specified page.
107        ///
108        /// - Parameters:
109        /// - observer: The observer object, which the extension will use to provide results.
110        /// - page: If a previous enumeration returned a `nextPage` on
111        /// ``-[NSFileProviderSearchEnumerationObserver finishEnumeratingUpToPage:]``,
112        /// the system may pass that page into the next enumeration.
113        /// The page should contain whatever information is needed to resume the enumeration.
114        #[unsafe(method(enumerateSearchResultsForObserver:startingAtPage:))]
115        #[unsafe(method_family = none)]
116        unsafe fn enumerateSearchResultsForObserver_startingAtPage(
117            &self,
118            observer: &ProtocolObject<dyn NSFileProviderSearchEnumerationObserver>,
119            page: Option<&NSFileProviderPage>,
120        );
121    }
122);
123
124extern_class!(
125    /// [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileproviderstringsearchrequest?language=objc)
126    #[unsafe(super(NSObject))]
127    #[derive(Debug, PartialEq, Eq, Hash)]
128    pub struct NSFileProviderStringSearchRequest;
129);
130
131extern_conformance!(
132    unsafe impl NSObjectProtocol for NSFileProviderStringSearchRequest {}
133);
134
135impl NSFileProviderStringSearchRequest {
136    extern_methods!(
137        /// A plaintext string, representing the query the user entered into the system search UI.
138        #[unsafe(method(query))]
139        #[unsafe(method_family = none)]
140        pub unsafe fn query(&self) -> Retained<NSString>;
141
142        /// How many results the system is requesting. This is a hint to the extension, to help avoid
143        /// unnecessary work. The extension may return more results than this.
144        #[unsafe(method(desiredNumberOfResults))]
145        #[unsafe(method_family = none)]
146        pub unsafe fn desiredNumberOfResults(&self) -> NSInteger;
147    );
148}
149
150/// Methods declared on superclass `NSObject`.
151impl NSFileProviderStringSearchRequest {
152    extern_methods!(
153        #[unsafe(method(init))]
154        #[unsafe(method_family = init)]
155        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
156
157        #[unsafe(method(new))]
158        #[unsafe(method_family = new)]
159        pub unsafe fn new() -> Retained<Self>;
160    );
161}
162
163extern_protocol!(
164    /// [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidersearching?language=objc)
165    pub unsafe trait NSFileProviderSearching: NSObjectProtocol {
166        /// Called by the system to retrieve search results for a user search query.
167        #[unsafe(method(searchEnumeratorForStringSearchRequest:))]
168        #[unsafe(method_family = none)]
169        unsafe fn searchEnumeratorForStringSearchRequest(
170            &self,
171            request: &NSFileProviderStringSearchRequest,
172        ) -> Retained<ProtocolObject<dyn NSFileProviderSearchEnumerator>>;
173    }
174);