1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
//! 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>>;
}
);