objc2_foundation/generated/
NSMetadata.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::*;
6
7use crate::*;
8
9extern_class!(
10    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataquery?language=objc)
11    #[unsafe(super(NSObject))]
12    #[derive(Debug, PartialEq, Eq, Hash)]
13    pub struct NSMetadataQuery;
14);
15
16extern_conformance!(
17    unsafe impl NSObjectProtocol for NSMetadataQuery {}
18);
19
20impl NSMetadataQuery {
21    extern_methods!(
22        /// # Safety
23        ///
24        /// This is not retained internally, you must ensure the object is still alive.
25        #[unsafe(method(delegate))]
26        #[unsafe(method_family = none)]
27        pub unsafe fn delegate(
28            &self,
29        ) -> Option<Retained<ProtocolObject<dyn NSMetadataQueryDelegate>>>;
30
31        /// Setter for [`delegate`][Self::delegate].
32        ///
33        /// # Safety
34        ///
35        /// This is unretained, you must ensure the object is kept alive while in use.
36        #[unsafe(method(setDelegate:))]
37        #[unsafe(method_family = none)]
38        pub unsafe fn setDelegate(
39            &self,
40            delegate: Option<&ProtocolObject<dyn NSMetadataQueryDelegate>>,
41        );
42
43        #[cfg(feature = "NSPredicate")]
44        #[unsafe(method(predicate))]
45        #[unsafe(method_family = none)]
46        pub fn predicate(&self) -> Option<Retained<NSPredicate>>;
47
48        #[cfg(feature = "NSPredicate")]
49        /// Setter for [`predicate`][Self::predicate].
50        ///
51        /// This is [copied][crate::NSCopying::copy] when set.
52        #[unsafe(method(setPredicate:))]
53        #[unsafe(method_family = none)]
54        pub fn setPredicate(&self, predicate: Option<&NSPredicate>);
55
56        #[cfg(all(feature = "NSArray", feature = "NSSortDescriptor"))]
57        #[unsafe(method(sortDescriptors))]
58        #[unsafe(method_family = none)]
59        pub fn sortDescriptors(&self) -> Retained<NSArray<NSSortDescriptor>>;
60
61        #[cfg(all(feature = "NSArray", feature = "NSSortDescriptor"))]
62        /// Setter for [`sortDescriptors`][Self::sortDescriptors].
63        ///
64        /// This is [copied][crate::NSCopying::copy] when set.
65        #[unsafe(method(setSortDescriptors:))]
66        #[unsafe(method_family = none)]
67        pub fn setSortDescriptors(&self, sort_descriptors: &NSArray<NSSortDescriptor>);
68
69        #[cfg(all(feature = "NSArray", feature = "NSString"))]
70        #[unsafe(method(valueListAttributes))]
71        #[unsafe(method_family = none)]
72        pub fn valueListAttributes(&self) -> Retained<NSArray<NSString>>;
73
74        #[cfg(all(feature = "NSArray", feature = "NSString"))]
75        /// Setter for [`valueListAttributes`][Self::valueListAttributes].
76        ///
77        /// This is [copied][crate::NSCopying::copy] when set.
78        #[unsafe(method(setValueListAttributes:))]
79        #[unsafe(method_family = none)]
80        pub fn setValueListAttributes(&self, value_list_attributes: &NSArray<NSString>);
81
82        #[cfg(all(feature = "NSArray", feature = "NSString"))]
83        #[unsafe(method(groupingAttributes))]
84        #[unsafe(method_family = none)]
85        pub fn groupingAttributes(&self) -> Option<Retained<NSArray<NSString>>>;
86
87        #[cfg(all(feature = "NSArray", feature = "NSString"))]
88        /// Setter for [`groupingAttributes`][Self::groupingAttributes].
89        ///
90        /// This is [copied][crate::NSCopying::copy] when set.
91        #[unsafe(method(setGroupingAttributes:))]
92        #[unsafe(method_family = none)]
93        pub fn setGroupingAttributes(&self, grouping_attributes: Option<&NSArray<NSString>>);
94
95        #[cfg(feature = "NSDate")]
96        #[unsafe(method(notificationBatchingInterval))]
97        #[unsafe(method_family = none)]
98        pub fn notificationBatchingInterval(&self) -> NSTimeInterval;
99
100        #[cfg(feature = "NSDate")]
101        /// Setter for [`notificationBatchingInterval`][Self::notificationBatchingInterval].
102        #[unsafe(method(setNotificationBatchingInterval:))]
103        #[unsafe(method_family = none)]
104        pub fn setNotificationBatchingInterval(
105            &self,
106            notification_batching_interval: NSTimeInterval,
107        );
108
109        #[cfg(feature = "NSArray")]
110        #[unsafe(method(searchScopes))]
111        #[unsafe(method_family = none)]
112        pub fn searchScopes(&self) -> Retained<NSArray>;
113
114        #[cfg(feature = "NSArray")]
115        /// Setter for [`searchScopes`][Self::searchScopes].
116        ///
117        /// This is [copied][crate::NSCopying::copy] when set.
118        ///
119        /// # Safety
120        ///
121        /// `search_scopes` generic should be of the correct type.
122        #[unsafe(method(setSearchScopes:))]
123        #[unsafe(method_family = none)]
124        pub unsafe fn setSearchScopes(&self, search_scopes: &NSArray);
125
126        #[cfg(feature = "NSArray")]
127        #[unsafe(method(searchItems))]
128        #[unsafe(method_family = none)]
129        pub fn searchItems(&self) -> Option<Retained<NSArray>>;
130
131        #[cfg(feature = "NSArray")]
132        /// Setter for [`searchItems`][Self::searchItems].
133        ///
134        /// This is [copied][crate::NSCopying::copy] when set.
135        ///
136        /// # Safety
137        ///
138        /// `search_items` generic should be of the correct type.
139        #[unsafe(method(setSearchItems:))]
140        #[unsafe(method_family = none)]
141        pub unsafe fn setSearchItems(&self, search_items: Option<&NSArray>);
142
143        #[cfg(feature = "NSOperation")]
144        #[unsafe(method(operationQueue))]
145        #[unsafe(method_family = none)]
146        pub fn operationQueue(&self) -> Option<Retained<NSOperationQueue>>;
147
148        #[cfg(feature = "NSOperation")]
149        /// Setter for [`operationQueue`][Self::operationQueue].
150        ///
151        /// # Safety
152        ///
153        /// `operation_queue` possibly has additional threading requirements.
154        #[unsafe(method(setOperationQueue:))]
155        #[unsafe(method_family = none)]
156        pub unsafe fn setOperationQueue(&self, operation_queue: Option<&NSOperationQueue>);
157
158        #[unsafe(method(startQuery))]
159        #[unsafe(method_family = none)]
160        pub fn startQuery(&self) -> bool;
161
162        #[unsafe(method(stopQuery))]
163        #[unsafe(method_family = none)]
164        pub fn stopQuery(&self);
165
166        #[unsafe(method(isStarted))]
167        #[unsafe(method_family = none)]
168        pub fn isStarted(&self) -> bool;
169
170        #[unsafe(method(isGathering))]
171        #[unsafe(method_family = none)]
172        pub fn isGathering(&self) -> bool;
173
174        #[unsafe(method(isStopped))]
175        #[unsafe(method_family = none)]
176        pub fn isStopped(&self) -> bool;
177
178        #[unsafe(method(disableUpdates))]
179        #[unsafe(method_family = none)]
180        pub fn disableUpdates(&self);
181
182        #[unsafe(method(enableUpdates))]
183        #[unsafe(method_family = none)]
184        pub fn enableUpdates(&self);
185
186        #[unsafe(method(resultCount))]
187        #[unsafe(method_family = none)]
188        pub fn resultCount(&self) -> NSUInteger;
189
190        #[unsafe(method(resultAtIndex:))]
191        #[unsafe(method_family = none)]
192        pub fn resultAtIndex(&self, idx: NSUInteger) -> Retained<AnyObject>;
193
194        #[cfg(feature = "block2")]
195        #[unsafe(method(enumerateResultsUsingBlock:))]
196        #[unsafe(method_family = none)]
197        pub fn enumerateResultsUsingBlock(
198            &self,
199            block: &block2::DynBlock<dyn Fn(NonNull<AnyObject>, NSUInteger, NonNull<Bool>) + '_>,
200        );
201
202        #[cfg(all(feature = "NSObjCRuntime", feature = "block2"))]
203        #[unsafe(method(enumerateResultsWithOptions:usingBlock:))]
204        #[unsafe(method_family = none)]
205        pub fn enumerateResultsWithOptions_usingBlock(
206            &self,
207            opts: NSEnumerationOptions,
208            block: &block2::DynBlock<dyn Fn(NonNull<AnyObject>, NSUInteger, NonNull<Bool>) + '_>,
209        );
210
211        #[cfg(feature = "NSArray")]
212        #[unsafe(method(results))]
213        #[unsafe(method_family = none)]
214        pub fn results(&self) -> Retained<NSArray>;
215
216        /// # Safety
217        ///
218        /// `result` should be of the correct type.
219        #[unsafe(method(indexOfResult:))]
220        #[unsafe(method_family = none)]
221        pub unsafe fn indexOfResult(&self, result: &AnyObject) -> NSUInteger;
222
223        #[cfg(all(feature = "NSArray", feature = "NSDictionary", feature = "NSString"))]
224        #[unsafe(method(valueLists))]
225        #[unsafe(method_family = none)]
226        pub fn valueLists(
227            &self,
228        ) -> Retained<NSDictionary<NSString, NSArray<NSMetadataQueryAttributeValueTuple>>>;
229
230        #[cfg(feature = "NSArray")]
231        #[unsafe(method(groupedResults))]
232        #[unsafe(method_family = none)]
233        pub fn groupedResults(&self) -> Retained<NSArray<NSMetadataQueryResultGroup>>;
234
235        #[cfg(feature = "NSString")]
236        #[unsafe(method(valueOfAttribute:forResultAtIndex:))]
237        #[unsafe(method_family = none)]
238        pub fn valueOfAttribute_forResultAtIndex(
239            &self,
240            attr_name: &NSString,
241            idx: NSUInteger,
242        ) -> Option<Retained<AnyObject>>;
243    );
244}
245
246/// Methods declared on superclass `NSObject`.
247impl NSMetadataQuery {
248    extern_methods!(
249        #[unsafe(method(init))]
250        #[unsafe(method_family = init)]
251        pub fn init(this: Allocated<Self>) -> Retained<Self>;
252
253        #[unsafe(method(new))]
254        #[unsafe(method_family = new)]
255        pub fn new() -> Retained<Self>;
256    );
257}
258
259impl DefaultRetained for NSMetadataQuery {
260    #[inline]
261    fn default_retained() -> Retained<Self> {
262        Self::new()
263    }
264}
265
266extern_protocol!(
267    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataquerydelegate?language=objc)
268    pub unsafe trait NSMetadataQueryDelegate: NSObjectProtocol {
269        #[optional]
270        #[unsafe(method(metadataQuery:replacementObjectForResultObject:))]
271        #[unsafe(method_family = none)]
272        fn metadataQuery_replacementObjectForResultObject(
273            &self,
274            query: &NSMetadataQuery,
275            result: &NSMetadataItem,
276        ) -> Retained<AnyObject>;
277
278        #[cfg(feature = "NSString")]
279        /// # Safety
280        ///
281        /// `attr_value` should be of the correct type.
282        #[optional]
283        #[unsafe(method(metadataQuery:replacementValueForAttribute:value:))]
284        #[unsafe(method_family = none)]
285        unsafe fn metadataQuery_replacementValueForAttribute_value(
286            &self,
287            query: &NSMetadataQuery,
288            attr_name: &NSString,
289            attr_value: &AnyObject,
290        ) -> Retained<AnyObject>;
291    }
292);
293
294extern "C" {
295    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataquerydidstartgatheringnotification?language=objc)
296    #[cfg(all(feature = "NSNotification", feature = "NSString"))]
297    pub static NSMetadataQueryDidStartGatheringNotification: &'static NSNotificationName;
298}
299
300extern "C" {
301    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataquerygatheringprogressnotification?language=objc)
302    #[cfg(all(feature = "NSNotification", feature = "NSString"))]
303    pub static NSMetadataQueryGatheringProgressNotification: &'static NSNotificationName;
304}
305
306extern "C" {
307    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataquerydidfinishgatheringnotification?language=objc)
308    #[cfg(all(feature = "NSNotification", feature = "NSString"))]
309    pub static NSMetadataQueryDidFinishGatheringNotification: &'static NSNotificationName;
310}
311
312extern "C" {
313    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataquerydidupdatenotification?language=objc)
314    #[cfg(all(feature = "NSNotification", feature = "NSString"))]
315    pub static NSMetadataQueryDidUpdateNotification: &'static NSNotificationName;
316}
317
318extern "C" {
319    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataqueryupdateaddeditemskey?language=objc)
320    #[cfg(feature = "NSString")]
321    pub static NSMetadataQueryUpdateAddedItemsKey: &'static NSString;
322}
323
324extern "C" {
325    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataqueryupdatechangeditemskey?language=objc)
326    #[cfg(feature = "NSString")]
327    pub static NSMetadataQueryUpdateChangedItemsKey: &'static NSString;
328}
329
330extern "C" {
331    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataqueryupdateremoveditemskey?language=objc)
332    #[cfg(feature = "NSString")]
333    pub static NSMetadataQueryUpdateRemovedItemsKey: &'static NSString;
334}
335
336extern "C" {
337    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataqueryresultcontentrelevanceattribute?language=objc)
338    #[cfg(feature = "NSString")]
339    pub static NSMetadataQueryResultContentRelevanceAttribute: &'static NSString;
340}
341
342extern "C" {
343    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataqueryuserhomescope?language=objc)
344    #[cfg(feature = "NSString")]
345    pub static NSMetadataQueryUserHomeScope: &'static NSString;
346}
347
348extern "C" {
349    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataquerylocalcomputerscope?language=objc)
350    #[cfg(feature = "NSString")]
351    pub static NSMetadataQueryLocalComputerScope: &'static NSString;
352}
353
354extern "C" {
355    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataquerynetworkscope?language=objc)
356    #[cfg(feature = "NSString")]
357    pub static NSMetadataQueryNetworkScope: &'static NSString;
358}
359
360extern "C" {
361    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataqueryindexedlocalcomputerscope?language=objc)
362    #[cfg(feature = "NSString")]
363    pub static NSMetadataQueryIndexedLocalComputerScope: &'static NSString;
364}
365
366extern "C" {
367    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataqueryindexednetworkscope?language=objc)
368    #[cfg(feature = "NSString")]
369    pub static NSMetadataQueryIndexedNetworkScope: &'static NSString;
370}
371
372extern "C" {
373    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataqueryubiquitousdocumentsscope?language=objc)
374    #[cfg(feature = "NSString")]
375    pub static NSMetadataQueryUbiquitousDocumentsScope: &'static NSString;
376}
377
378extern "C" {
379    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataqueryubiquitousdatascope?language=objc)
380    #[cfg(feature = "NSString")]
381    pub static NSMetadataQueryUbiquitousDataScope: &'static NSString;
382}
383
384extern "C" {
385    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataqueryaccessibleubiquitousexternaldocumentsscope?language=objc)
386    #[cfg(feature = "NSString")]
387    pub static NSMetadataQueryAccessibleUbiquitousExternalDocumentsScope: &'static NSString;
388}
389
390extern_class!(
391    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataitem?language=objc)
392    #[unsafe(super(NSObject))]
393    #[derive(Debug, PartialEq, Eq, Hash)]
394    pub struct NSMetadataItem;
395);
396
397extern_conformance!(
398    unsafe impl NSObjectProtocol for NSMetadataItem {}
399);
400
401impl NSMetadataItem {
402    extern_methods!(
403        #[cfg(feature = "NSURL")]
404        #[unsafe(method(initWithURL:))]
405        #[unsafe(method_family = init)]
406        pub fn initWithURL(this: Allocated<Self>, url: &NSURL) -> Option<Retained<Self>>;
407
408        #[cfg(feature = "NSString")]
409        #[unsafe(method(valueForAttribute:))]
410        #[unsafe(method_family = none)]
411        pub fn valueForAttribute(&self, key: &NSString) -> Option<Retained<AnyObject>>;
412
413        #[cfg(all(feature = "NSArray", feature = "NSDictionary", feature = "NSString"))]
414        #[unsafe(method(valuesForAttributes:))]
415        #[unsafe(method_family = none)]
416        pub fn valuesForAttributes(
417            &self,
418            keys: &NSArray<NSString>,
419        ) -> Option<Retained<NSDictionary<NSString, AnyObject>>>;
420
421        #[cfg(all(feature = "NSArray", feature = "NSString"))]
422        #[unsafe(method(attributes))]
423        #[unsafe(method_family = none)]
424        pub fn attributes(&self) -> Retained<NSArray<NSString>>;
425    );
426}
427
428/// Methods declared on superclass `NSObject`.
429impl NSMetadataItem {
430    extern_methods!(
431        #[unsafe(method(init))]
432        #[unsafe(method_family = init)]
433        pub fn init(this: Allocated<Self>) -> Retained<Self>;
434
435        #[unsafe(method(new))]
436        #[unsafe(method_family = new)]
437        pub fn new() -> Retained<Self>;
438    );
439}
440
441impl DefaultRetained for NSMetadataItem {
442    #[inline]
443    fn default_retained() -> Retained<Self> {
444        Self::new()
445    }
446}
447
448extern_class!(
449    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataqueryattributevaluetuple?language=objc)
450    #[unsafe(super(NSObject))]
451    #[derive(Debug, PartialEq, Eq, Hash)]
452    pub struct NSMetadataQueryAttributeValueTuple;
453);
454
455extern_conformance!(
456    unsafe impl NSObjectProtocol for NSMetadataQueryAttributeValueTuple {}
457);
458
459impl NSMetadataQueryAttributeValueTuple {
460    extern_methods!(
461        #[cfg(feature = "NSString")]
462        #[unsafe(method(attribute))]
463        #[unsafe(method_family = none)]
464        pub fn attribute(&self) -> Retained<NSString>;
465
466        #[unsafe(method(value))]
467        #[unsafe(method_family = none)]
468        pub fn value(&self) -> Option<Retained<AnyObject>>;
469
470        #[unsafe(method(count))]
471        #[unsafe(method_family = none)]
472        pub fn count(&self) -> NSUInteger;
473    );
474}
475
476/// Methods declared on superclass `NSObject`.
477impl NSMetadataQueryAttributeValueTuple {
478    extern_methods!(
479        #[unsafe(method(init))]
480        #[unsafe(method_family = init)]
481        pub fn init(this: Allocated<Self>) -> Retained<Self>;
482
483        #[unsafe(method(new))]
484        #[unsafe(method_family = new)]
485        pub fn new() -> Retained<Self>;
486    );
487}
488
489impl DefaultRetained for NSMetadataQueryAttributeValueTuple {
490    #[inline]
491    fn default_retained() -> Retained<Self> {
492        Self::new()
493    }
494}
495
496extern_class!(
497    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmetadataqueryresultgroup?language=objc)
498    #[unsafe(super(NSObject))]
499    #[derive(Debug, PartialEq, Eq, Hash)]
500    pub struct NSMetadataQueryResultGroup;
501);
502
503extern_conformance!(
504    unsafe impl NSObjectProtocol for NSMetadataQueryResultGroup {}
505);
506
507impl NSMetadataQueryResultGroup {
508    extern_methods!(
509        #[cfg(feature = "NSString")]
510        #[unsafe(method(attribute))]
511        #[unsafe(method_family = none)]
512        pub fn attribute(&self) -> Retained<NSString>;
513
514        #[unsafe(method(value))]
515        #[unsafe(method_family = none)]
516        pub fn value(&self) -> Retained<AnyObject>;
517
518        #[cfg(feature = "NSArray")]
519        #[unsafe(method(subgroups))]
520        #[unsafe(method_family = none)]
521        pub fn subgroups(&self) -> Option<Retained<NSArray<NSMetadataQueryResultGroup>>>;
522
523        #[unsafe(method(resultCount))]
524        #[unsafe(method_family = none)]
525        pub fn resultCount(&self) -> NSUInteger;
526
527        #[unsafe(method(resultAtIndex:))]
528        #[unsafe(method_family = none)]
529        pub fn resultAtIndex(&self, idx: NSUInteger) -> Retained<AnyObject>;
530
531        #[cfg(feature = "NSArray")]
532        #[unsafe(method(results))]
533        #[unsafe(method_family = none)]
534        pub fn results(&self) -> Retained<NSArray>;
535    );
536}
537
538/// Methods declared on superclass `NSObject`.
539impl NSMetadataQueryResultGroup {
540    extern_methods!(
541        #[unsafe(method(init))]
542        #[unsafe(method_family = init)]
543        pub fn init(this: Allocated<Self>) -> Retained<Self>;
544
545        #[unsafe(method(new))]
546        #[unsafe(method_family = new)]
547        pub fn new() -> Retained<Self>;
548    );
549}
550
551impl DefaultRetained for NSMetadataQueryResultGroup {
552    #[inline]
553    fn default_retained() -> Retained<Self> {
554        Self::new()
555    }
556}