objc2_app_kit/generated/
NSPasteboard.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
8use crate::*;
9
10/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtype?language=objc)
11// NS_TYPED_EXTENSIBLE_ENUM
12pub type NSPasteboardType = NSString;
13
14extern "C" {
15    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtypestring?language=objc)
16    pub static NSPasteboardTypeString: &'static NSPasteboardType;
17}
18
19extern "C" {
20    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtypepdf?language=objc)
21    pub static NSPasteboardTypePDF: &'static NSPasteboardType;
22}
23
24extern "C" {
25    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtypetiff?language=objc)
26    pub static NSPasteboardTypeTIFF: &'static NSPasteboardType;
27}
28
29extern "C" {
30    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtypepng?language=objc)
31    pub static NSPasteboardTypePNG: &'static NSPasteboardType;
32}
33
34extern "C" {
35    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtypertf?language=objc)
36    pub static NSPasteboardTypeRTF: &'static NSPasteboardType;
37}
38
39extern "C" {
40    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtypertfd?language=objc)
41    pub static NSPasteboardTypeRTFD: &'static NSPasteboardType;
42}
43
44extern "C" {
45    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtypehtml?language=objc)
46    pub static NSPasteboardTypeHTML: &'static NSPasteboardType;
47}
48
49extern "C" {
50    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtypetabulartext?language=objc)
51    pub static NSPasteboardTypeTabularText: &'static NSPasteboardType;
52}
53
54extern "C" {
55    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtypefont?language=objc)
56    pub static NSPasteboardTypeFont: &'static NSPasteboardType;
57}
58
59extern "C" {
60    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtyperuler?language=objc)
61    pub static NSPasteboardTypeRuler: &'static NSPasteboardType;
62}
63
64extern "C" {
65    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtypecolor?language=objc)
66    pub static NSPasteboardTypeColor: &'static NSPasteboardType;
67}
68
69extern "C" {
70    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtypesound?language=objc)
71    pub static NSPasteboardTypeSound: &'static NSPasteboardType;
72}
73
74extern "C" {
75    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtypemultipletextselection?language=objc)
76    pub static NSPasteboardTypeMultipleTextSelection: &'static NSPasteboardType;
77}
78
79extern "C" {
80    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtypetextfinderoptions?language=objc)
81    pub static NSPasteboardTypeTextFinderOptions: &'static NSPasteboardType;
82}
83
84extern "C" {
85    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtypeurl?language=objc)
86    pub static NSPasteboardTypeURL: &'static NSPasteboardType;
87}
88
89extern "C" {
90    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtypefileurl?language=objc)
91    pub static NSPasteboardTypeFileURL: &'static NSPasteboardType;
92}
93
94/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardname?language=objc)
95// NS_TYPED_EXTENSIBLE_ENUM
96pub type NSPasteboardName = NSString;
97
98extern "C" {
99    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardnamegeneral?language=objc)
100    pub static NSPasteboardNameGeneral: &'static NSPasteboardName;
101}
102
103extern "C" {
104    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardnamefont?language=objc)
105    pub static NSPasteboardNameFont: &'static NSPasteboardName;
106}
107
108extern "C" {
109    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardnameruler?language=objc)
110    pub static NSPasteboardNameRuler: &'static NSPasteboardName;
111}
112
113extern "C" {
114    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardnamefind?language=objc)
115    pub static NSPasteboardNameFind: &'static NSPasteboardName;
116}
117
118extern "C" {
119    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardnamedrag?language=objc)
120    pub static NSPasteboardNameDrag: &'static NSPasteboardName;
121}
122
123/// A value indicating pasteboard access behavior.
124///
125/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardaccessbehavior?language=objc)
126// NS_ENUM
127#[repr(transparent)]
128#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
129pub struct NSPasteboardAccessBehavior(pub NSInteger);
130impl NSPasteboardAccessBehavior {
131    /// The default behavior for the General pasteboard is to ask upon programmatic access. All other pasteboards default to always allow access.
132    /// If an app has never triggered a pasteboard access alert, its General pasteboard will report `.default` behavior. Such an app is not shown in the corresponding System Settings pane.
133    /// Once programmatic pasteboard access triggers the first pasteboard access alert, the state automatically changes to `.ask`. At this point the app starts being shown in System Settings, where the user can toggle the behavior between `.ask`, `.alwaysAllow`, and `.alwaysDeny`.
134    #[doc(alias = "NSPasteboardAccessBehaviorDefault")]
135    pub const Default: Self = Self(0);
136    /// The system will notify the user and ask for permission before granting pasteboard access. However, access that is both user originated and paste related will always be allowed, and will not result in a notification. The app is listed in the corresponding System Settings pane.
137    #[doc(alias = "NSPasteboardAccessBehaviorAsk")]
138    pub const Ask: Self = Self(1);
139    /// The system will automatically allow all pasteboard access, without notifying the user.  The app is listed in the corresponding System Settings pane.
140    #[doc(alias = "NSPasteboardAccessBehaviorAlwaysAllow")]
141    pub const AlwaysAllow: Self = Self(2);
142    /// The system will automatically deny all pasteboard access, without notifying the user. However, access that is both user originated and paste related will always be allowed, and will not result in a notification. The app is listed in the corresponding System Settings pane.
143    #[doc(alias = "NSPasteboardAccessBehaviorAlwaysDeny")]
144    pub const AlwaysDeny: Self = Self(3);
145}
146
147unsafe impl Encode for NSPasteboardAccessBehavior {
148    const ENCODING: Encoding = NSInteger::ENCODING;
149}
150
151unsafe impl RefEncode for NSPasteboardAccessBehavior {
152    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
153}
154
155/// A pattern to detect on the pasteboard, such as a URL, text, or a number.
156///
157/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboarddetectionpattern?language=objc)
158// NS_TYPED_ENUM
159pub type NSPasteboardDetectionPattern = NSString;
160
161extern "C" {
162    /// A pattern that indicates the pasteboard detects a string that consists of a web URL.
163    ///
164    /// Returns: NSString value, suitable for implementing "Paste and Go"
165    ///
166    /// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboarddetectionpatternprobableweburl?language=objc)
167    pub static NSPasteboardDetectionPatternProbableWebURL: &'static NSPasteboardDetectionPattern;
168}
169
170extern "C" {
171    /// A pattern that indicates the pasteboard detects a string suitable for use as a web search term.
172    ///
173    /// Returns: NSString value, suitable for implementing "Paste and Search"
174    ///
175    /// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboarddetectionpatternprobablewebsearch?language=objc)
176    pub static NSPasteboardDetectionPatternProbableWebSearch: &'static NSPasteboardDetectionPattern;
177}
178
179extern "C" {
180    /// A pattern that indicates the pasteboard detects a string that consists of a numeric value.
181    ///
182    /// Returns: NSNumber value
183    ///
184    /// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboarddetectionpatternnumber?language=objc)
185    pub static NSPasteboardDetectionPatternNumber: &'static NSPasteboardDetectionPattern;
186}
187
188extern "C" {
189    /// A pattern that indicates the pasteboard detects a string that contains a URL.
190    ///
191    /// Returns: array of DDMatchLink values
192    ///
193    /// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboarddetectionpatternlink?language=objc)
194    pub static NSPasteboardDetectionPatternLink: &'static NSPasteboardDetectionPattern;
195}
196
197extern "C" {
198    /// A pattern that indicates the pasteboard detects a string that contains a phone number.
199    ///
200    /// Returns: array of DDMatchPhoneNumber values
201    ///
202    /// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboarddetectionpatternphonenumber?language=objc)
203    pub static NSPasteboardDetectionPatternPhoneNumber: &'static NSPasteboardDetectionPattern;
204}
205
206extern "C" {
207    /// A pattern that indicates the pasteboard detects a string that contains an email address.
208    ///
209    /// Returns: array of DDMatchEmailAddress values
210    ///
211    /// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboarddetectionpatternemailaddress?language=objc)
212    pub static NSPasteboardDetectionPatternEmailAddress: &'static NSPasteboardDetectionPattern;
213}
214
215extern "C" {
216    /// A pattern that indicates the pasteboard detects a string that contains a postal address.
217    ///
218    /// Returns: array of DDMatchPostalAddress values
219    ///
220    /// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboarddetectionpatternpostaladdress?language=objc)
221    pub static NSPasteboardDetectionPatternPostalAddress: &'static NSPasteboardDetectionPattern;
222}
223
224extern "C" {
225    /// A pattern that indicates the pasteboard detects a string that contains a calendar event.
226    ///
227    /// Returns: array of DDMatchCalendarEvent values
228    ///
229    /// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboarddetectionpatterncalendarevent?language=objc)
230    pub static NSPasteboardDetectionPatternCalendarEvent: &'static NSPasteboardDetectionPattern;
231}
232
233extern "C" {
234    /// A pattern that indicates the pasteboard detects a string that contains a parcel tracking number and carrier.
235    ///
236    /// Returns: array of DDMatchShipmentTrackingNumber values
237    ///
238    /// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboarddetectionpatternshipmenttrackingnumber?language=objc)
239    pub static NSPasteboardDetectionPatternShipmentTrackingNumber:
240        &'static NSPasteboardDetectionPattern;
241}
242
243extern "C" {
244    /// A pattern that indicates the pasteboard detects a string that contains a flight number.
245    ///
246    /// Returns: array of DDMatchFlightNumber values
247    ///
248    /// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboarddetectionpatternflightnumber?language=objc)
249    pub static NSPasteboardDetectionPatternFlightNumber: &'static NSPasteboardDetectionPattern;
250}
251
252extern "C" {
253    /// A pattern that indicates the pasteboard detects a string that contains an amount of money.
254    ///
255    /// Returns: array of DDMatchMoneyAmount values
256    ///
257    /// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboarddetectionpatternmoneyamount?language=objc)
258    pub static NSPasteboardDetectionPatternMoneyAmount: &'static NSPasteboardDetectionPattern;
259}
260
261/// A metadata type to detect on the pasteboard.
262///
263/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardmetadatatype?language=objc)
264// NS_TYPED_ENUM
265pub type NSPasteboardMetadataType = NSString;
266
267extern "C" {
268    /// A metadata type that returns the content type if the pasteboard detects a reference to a file.
269    ///
270    /// Returns: UTType value for the detected content type of the file URL, if a file URL type is present.
271    ///
272    /// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardmetadatatypecontenttype?language=objc)
273    pub static NSPasteboardMetadataTypeContentType: &'static NSPasteboardMetadataType;
274}
275
276/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardcontentsoptions?language=objc)
277// NS_OPTIONS
278#[repr(transparent)]
279#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
280pub struct NSPasteboardContentsOptions(pub NSUInteger);
281bitflags::bitflags! {
282    impl NSPasteboardContentsOptions: NSUInteger {
283        #[doc(alias = "NSPasteboardContentsCurrentHostOnly")]
284        const CurrentHostOnly = 1<<0;
285    }
286}
287
288unsafe impl Encode for NSPasteboardContentsOptions {
289    const ENCODING: Encoding = NSUInteger::ENCODING;
290}
291
292unsafe impl RefEncode for NSPasteboardContentsOptions {
293    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
294}
295
296/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardreadingoptionkey?language=objc)
297// NS_TYPED_ENUM
298pub type NSPasteboardReadingOptionKey = NSString;
299
300extern "C" {
301    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardurlreadingfileurlsonlykey?language=objc)
302    pub static NSPasteboardURLReadingFileURLsOnlyKey: &'static NSPasteboardReadingOptionKey;
303}
304
305extern "C" {
306    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardurlreadingcontentsconformtotypeskey?language=objc)
307    pub static NSPasteboardURLReadingContentsConformToTypesKey:
308        &'static NSPasteboardReadingOptionKey;
309}
310
311extern_class!(
312    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboard?language=objc)
313    #[unsafe(super(NSObject))]
314    #[derive(Debug, PartialEq, Eq, Hash)]
315    pub struct NSPasteboard;
316);
317
318extern_conformance!(
319    unsafe impl NSObjectProtocol for NSPasteboard {}
320);
321
322impl NSPasteboard {
323    extern_methods!(
324        #[unsafe(method(generalPasteboard))]
325        #[unsafe(method_family = none)]
326        pub unsafe fn generalPasteboard() -> Retained<NSPasteboard>;
327
328        #[unsafe(method(pasteboardWithName:))]
329        #[unsafe(method_family = none)]
330        pub unsafe fn pasteboardWithName(name: &NSPasteboardName) -> Retained<NSPasteboard>;
331
332        #[unsafe(method(pasteboardWithUniqueName))]
333        #[unsafe(method_family = none)]
334        pub unsafe fn pasteboardWithUniqueName() -> Retained<NSPasteboard>;
335
336        #[unsafe(method(name))]
337        #[unsafe(method_family = none)]
338        pub unsafe fn name(&self) -> Retained<NSPasteboardName>;
339
340        #[unsafe(method(changeCount))]
341        #[unsafe(method_family = none)]
342        pub unsafe fn changeCount(&self) -> NSInteger;
343
344        /// The current pasteboard access behavior. The user can customize this behavior per-app in System Settings for any app that has triggered a pasteboard access alert in the past.
345        #[unsafe(method(accessBehavior))]
346        #[unsafe(method_family = none)]
347        pub unsafe fn accessBehavior(&self) -> NSPasteboardAccessBehavior;
348
349        #[unsafe(method(prepareForNewContentsWithOptions:))]
350        #[unsafe(method_family = none)]
351        pub unsafe fn prepareForNewContentsWithOptions(
352            &self,
353            options: NSPasteboardContentsOptions,
354        ) -> NSInteger;
355
356        #[unsafe(method(clearContents))]
357        #[unsafe(method_family = none)]
358        pub unsafe fn clearContents(&self) -> NSInteger;
359
360        #[unsafe(method(writeObjects:))]
361        #[unsafe(method_family = none)]
362        pub unsafe fn writeObjects(
363            &self,
364            objects: &NSArray<ProtocolObject<dyn NSPasteboardWriting>>,
365        ) -> bool;
366
367        #[unsafe(method(readObjectsForClasses:options:))]
368        #[unsafe(method_family = none)]
369        pub unsafe fn readObjectsForClasses_options(
370            &self,
371            class_array: &NSArray<AnyClass>,
372            options: Option<&NSDictionary<NSPasteboardReadingOptionKey, AnyObject>>,
373        ) -> Option<Retained<NSArray>>;
374
375        #[cfg(feature = "NSPasteboardItem")]
376        #[unsafe(method(pasteboardItems))]
377        #[unsafe(method_family = none)]
378        pub unsafe fn pasteboardItems(&self) -> Option<Retained<NSArray<NSPasteboardItem>>>;
379
380        #[cfg(feature = "NSPasteboardItem")]
381        #[unsafe(method(indexOfPasteboardItem:))]
382        #[unsafe(method_family = none)]
383        pub unsafe fn indexOfPasteboardItem(
384            &self,
385            pasteboard_item: &NSPasteboardItem,
386        ) -> NSUInteger;
387
388        #[unsafe(method(canReadItemWithDataConformingToTypes:))]
389        #[unsafe(method_family = none)]
390        pub unsafe fn canReadItemWithDataConformingToTypes(
391            &self,
392            types: &NSArray<NSString>,
393        ) -> bool;
394
395        #[unsafe(method(canReadObjectForClasses:options:))]
396        #[unsafe(method_family = none)]
397        pub unsafe fn canReadObjectForClasses_options(
398            &self,
399            class_array: &NSArray<AnyClass>,
400            options: Option<&NSDictionary<NSPasteboardReadingOptionKey, AnyObject>>,
401        ) -> bool;
402
403        #[unsafe(method(declareTypes:owner:))]
404        #[unsafe(method_family = none)]
405        pub unsafe fn declareTypes_owner(
406            &self,
407            new_types: &NSArray<NSPasteboardType>,
408            new_owner: Option<&AnyObject>,
409        ) -> NSInteger;
410
411        #[unsafe(method(addTypes:owner:))]
412        #[unsafe(method_family = none)]
413        pub unsafe fn addTypes_owner(
414            &self,
415            new_types: &NSArray<NSPasteboardType>,
416            new_owner: Option<&AnyObject>,
417        ) -> NSInteger;
418
419        #[unsafe(method(types))]
420        #[unsafe(method_family = none)]
421        pub unsafe fn types(&self) -> Option<Retained<NSArray<NSPasteboardType>>>;
422
423        #[unsafe(method(availableTypeFromArray:))]
424        #[unsafe(method_family = none)]
425        pub unsafe fn availableTypeFromArray(
426            &self,
427            types: &NSArray<NSPasteboardType>,
428        ) -> Option<Retained<NSPasteboardType>>;
429
430        #[unsafe(method(setData:forType:))]
431        #[unsafe(method_family = none)]
432        pub unsafe fn setData_forType(
433            &self,
434            data: Option<&NSData>,
435            data_type: &NSPasteboardType,
436        ) -> bool;
437
438        #[unsafe(method(setPropertyList:forType:))]
439        #[unsafe(method_family = none)]
440        pub unsafe fn setPropertyList_forType(
441            &self,
442            plist: &AnyObject,
443            data_type: &NSPasteboardType,
444        ) -> bool;
445
446        #[unsafe(method(setString:forType:))]
447        #[unsafe(method_family = none)]
448        pub unsafe fn setString_forType(
449            &self,
450            string: &NSString,
451            data_type: &NSPasteboardType,
452        ) -> bool;
453
454        #[unsafe(method(dataForType:))]
455        #[unsafe(method_family = none)]
456        pub unsafe fn dataForType(&self, data_type: &NSPasteboardType) -> Option<Retained<NSData>>;
457
458        #[unsafe(method(propertyListForType:))]
459        #[unsafe(method_family = none)]
460        pub fn propertyListForType(
461            &self,
462            data_type: &NSPasteboardType,
463        ) -> Option<Retained<AnyObject>>;
464
465        #[unsafe(method(stringForType:))]
466        #[unsafe(method_family = none)]
467        pub unsafe fn stringForType(
468            &self,
469            data_type: &NSPasteboardType,
470        ) -> Option<Retained<NSString>>;
471
472        #[cfg(feature = "block2")]
473        /// Determines whether the first pasteboard item matches the specified patterns, without notifying the user.
474        ///
475        /// Because this method only gives an indication of whether a pasteboard item matches a particular pattern and doesn’t allow the app to access the contents, the system doesn’t notify the user about reading the contents of the pasteboard.
476        ///
477        ///
478        /// Parameter `patterns`: The patterns to detect on the pasteboard.
479        ///
480        /// Parameter `completionHandler`: A block that the system invokes after detecting patterns on the pasteboard. The block receives either a set with the patterns found on the pasteboard or an error if detection failed.
481        #[unsafe(method(detectPatternsForPatterns:completionHandler:))]
482        #[unsafe(method_family = none)]
483        pub unsafe fn detectPatternsForPatterns_completionHandler(
484            &self,
485            patterns: &NSSet<NSPasteboardDetectionPattern>,
486            completion_handler: &block2::DynBlock<
487                dyn Fn(*mut NSSet<NSPasteboardDetectionPattern>, *mut NSError),
488            >,
489        );
490
491        #[cfg(feature = "block2")]
492        /// Determines whether the first pasteboard item matches the specified patterns, reading the contents if it finds a match.
493        ///
494        /// - Important: Calling this method notifies the user that the app has read the contents of the pasteboard, if a match is found.
495        ///
496        /// For details about the types returned for each pattern, see `NSPasteboardDetectionPattern`.
497        ///
498        ///
499        /// Parameter `patterns`: The patterns to detect on the pasteboard.
500        ///
501        /// Parameter `completionHandler`: A block that the system invokes after detecting patterns on the pasteboard. The block returns either dictionary with the patterns found on the pasteboard or an error if detection failed. The dictionary keys specify the matched patterns, and the values specify the corresponding content of the pasteboard.
502        #[unsafe(method(detectValuesForPatterns:completionHandler:))]
503        #[unsafe(method_family = none)]
504        pub unsafe fn detectValuesForPatterns_completionHandler(
505            &self,
506            patterns: &NSSet<NSPasteboardDetectionPattern>,
507            completion_handler: &block2::DynBlock<
508                dyn Fn(*mut NSDictionary<NSPasteboardDetectionPattern, AnyObject>, *mut NSError),
509            >,
510        );
511
512        #[cfg(feature = "block2")]
513        /// Determines available metadata from the specified metadata types for the first pasteboard item, without notifying the user.
514        ///
515        /// Because this method only gives access to limited types of metadata and doesn’t allow the app to access the contents, the system doesn’t notify the user about reading the contents of the pasteboard.
516        ///
517        /// For details about the metadata returned for each type, see `NSPasteboardMetadataType`.
518        ///
519        ///
520        /// Parameter `types`: The metadata types to detect on the pasteboard.
521        ///
522        /// Parameter `completionHandler`: A block that the system invokes after detecting metadata on the pasteboard. The block receives either a dictionary with the metadata types found on the pasteboard or an error if detection failed. The dictionary keys specify the matched metadata types, and the values specify the corresponding metadata.
523        #[unsafe(method(detectMetadataForTypes:completionHandler:))]
524        #[unsafe(method_family = none)]
525        pub unsafe fn detectMetadataForTypes_completionHandler(
526            &self,
527            types: &NSSet<NSPasteboardMetadataType>,
528            completion_handler: &block2::DynBlock<
529                dyn Fn(*mut NSDictionary<NSPasteboardMetadataType, AnyObject>, *mut NSError),
530            >,
531        );
532    );
533}
534
535/// Methods declared on superclass `NSObject`.
536impl NSPasteboard {
537    extern_methods!(
538        #[unsafe(method(init))]
539        #[unsafe(method_family = init)]
540        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
541
542        #[unsafe(method(new))]
543        #[unsafe(method_family = new)]
544        pub unsafe fn new() -> Retained<Self>;
545    );
546}
547
548/// FilterServices.
549impl NSPasteboard {
550    extern_methods!(
551        #[unsafe(method(typesFilterableTo:))]
552        #[unsafe(method_family = none)]
553        pub unsafe fn typesFilterableTo(
554            r#type: &NSPasteboardType,
555        ) -> Retained<NSArray<NSPasteboardType>>;
556
557        #[unsafe(method(pasteboardByFilteringFile:))]
558        #[unsafe(method_family = none)]
559        pub unsafe fn pasteboardByFilteringFile(filename: &NSString) -> Retained<NSPasteboard>;
560
561        #[unsafe(method(pasteboardByFilteringData:ofType:))]
562        #[unsafe(method_family = none)]
563        pub unsafe fn pasteboardByFilteringData_ofType(
564            data: &NSData,
565            r#type: &NSPasteboardType,
566        ) -> Retained<NSPasteboard>;
567
568        #[unsafe(method(pasteboardByFilteringTypesInPasteboard:))]
569        #[unsafe(method_family = none)]
570        pub unsafe fn pasteboardByFilteringTypesInPasteboard(
571            pboard: &NSPasteboard,
572        ) -> Retained<NSPasteboard>;
573    );
574}
575
576extern_protocol!(
577    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtypeowner?language=objc)
578    pub unsafe trait NSPasteboardTypeOwner: NSObjectProtocol {
579        #[unsafe(method(pasteboard:provideDataForType:))]
580        #[unsafe(method_family = none)]
581        unsafe fn pasteboard_provideDataForType(
582            &self,
583            sender: &NSPasteboard,
584            r#type: &NSPasteboardType,
585        );
586
587        #[optional]
588        #[unsafe(method(pasteboardChangedOwner:))]
589        #[unsafe(method_family = none)]
590        unsafe fn pasteboardChangedOwner(&self, sender: &NSPasteboard);
591    }
592);
593
594/// * NSPasteboardWriting and NSPasteboardReading Protocols **
595///
596/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardwritingoptions?language=objc)
597// NS_OPTIONS
598#[repr(transparent)]
599#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
600pub struct NSPasteboardWritingOptions(pub NSUInteger);
601bitflags::bitflags! {
602    impl NSPasteboardWritingOptions: NSUInteger {
603        #[doc(alias = "NSPasteboardWritingPromised")]
604        const Promised = 1<<9;
605    }
606}
607
608unsafe impl Encode for NSPasteboardWritingOptions {
609    const ENCODING: Encoding = NSUInteger::ENCODING;
610}
611
612unsafe impl RefEncode for NSPasteboardWritingOptions {
613    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
614}
615
616extern_protocol!(
617    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardwriting?language=objc)
618    pub unsafe trait NSPasteboardWriting: NSObjectProtocol {
619        #[unsafe(method(writableTypesForPasteboard:))]
620        #[unsafe(method_family = none)]
621        unsafe fn writableTypesForPasteboard(
622            &self,
623            pasteboard: &NSPasteboard,
624        ) -> Retained<NSArray<NSPasteboardType>>;
625
626        #[optional]
627        #[unsafe(method(writingOptionsForType:pasteboard:))]
628        #[unsafe(method_family = none)]
629        unsafe fn writingOptionsForType_pasteboard(
630            &self,
631            r#type: &NSPasteboardType,
632            pasteboard: &NSPasteboard,
633        ) -> NSPasteboardWritingOptions;
634
635        #[unsafe(method(pasteboardPropertyListForType:))]
636        #[unsafe(method_family = none)]
637        unsafe fn pasteboardPropertyListForType(
638            &self,
639            r#type: &NSPasteboardType,
640        ) -> Option<Retained<AnyObject>>;
641    }
642);
643
644/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardreadingoptions?language=objc)
645// NS_OPTIONS
646#[repr(transparent)]
647#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
648pub struct NSPasteboardReadingOptions(pub NSUInteger);
649bitflags::bitflags! {
650    impl NSPasteboardReadingOptions: NSUInteger {
651        #[doc(alias = "NSPasteboardReadingAsData")]
652        const AsData = 0;
653        #[doc(alias = "NSPasteboardReadingAsString")]
654        const AsString = 1<<0;
655        #[doc(alias = "NSPasteboardReadingAsPropertyList")]
656        const AsPropertyList = 1<<1;
657        #[doc(alias = "NSPasteboardReadingAsKeyedArchive")]
658        const AsKeyedArchive = 1<<2;
659    }
660}
661
662unsafe impl Encode for NSPasteboardReadingOptions {
663    const ENCODING: Encoding = NSUInteger::ENCODING;
664}
665
666unsafe impl RefEncode for NSPasteboardReadingOptions {
667    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
668}
669
670extern_protocol!(
671    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardreading?language=objc)
672    pub unsafe trait NSPasteboardReading: NSObjectProtocol {
673        #[unsafe(method(readableTypesForPasteboard:))]
674        #[unsafe(method_family = none)]
675        unsafe fn readableTypesForPasteboard(
676            pasteboard: &NSPasteboard,
677        ) -> Retained<NSArray<NSPasteboardType>>;
678
679        #[optional]
680        #[unsafe(method(readingOptionsForType:pasteboard:))]
681        #[unsafe(method_family = none)]
682        unsafe fn readingOptionsForType_pasteboard(
683            r#type: &NSPasteboardType,
684            pasteboard: &NSPasteboard,
685        ) -> NSPasteboardReadingOptions;
686
687        #[optional]
688        #[unsafe(method(initWithPasteboardPropertyList:ofType:))]
689        #[unsafe(method_family = init)]
690        unsafe fn initWithPasteboardPropertyList_ofType(
691            this: Allocated<Self>,
692            property_list: &AnyObject,
693            r#type: &NSPasteboardType,
694        ) -> Option<Retained<Self>>;
695    }
696);
697
698mod private_NSURLNSPasteboardSupport {
699    pub trait Sealed {}
700}
701
702/// Category "NSPasteboardSupport" on [`NSURL`].
703#[doc(alias = "NSPasteboardSupport")]
704pub unsafe trait NSURLNSPasteboardSupport:
705    ClassType + Sized + private_NSURLNSPasteboardSupport::Sealed
706{
707    extern_methods!(
708        #[unsafe(method(URLFromPasteboard:))]
709        #[unsafe(method_family = none)]
710        unsafe fn URLFromPasteboard(paste_board: &NSPasteboard) -> Option<Retained<NSURL>>;
711
712        #[unsafe(method(writeToPasteboard:))]
713        #[unsafe(method_family = none)]
714        unsafe fn writeToPasteboard(&self, paste_board: &NSPasteboard);
715    );
716}
717
718impl private_NSURLNSPasteboardSupport::Sealed for NSURL {}
719unsafe impl NSURLNSPasteboardSupport for NSURL {}
720
721extern_conformance!(
722    unsafe impl NSPasteboardReading for NSURL {}
723);
724
725extern_conformance!(
726    unsafe impl NSPasteboardWriting for NSURL {}
727);
728
729extern_conformance!(
730    unsafe impl NSPasteboardReading for NSString {}
731);
732
733extern_conformance!(
734    unsafe impl NSPasteboardWriting for NSString {}
735);
736
737/// NSFileContents.
738/// * File Contents **
739impl NSPasteboard {
740    extern_methods!(
741        #[unsafe(method(writeFileContents:))]
742        #[unsafe(method_family = none)]
743        pub unsafe fn writeFileContents(&self, filename: &NSString) -> bool;
744
745        #[unsafe(method(readFileContentsType:toFile:))]
746        #[unsafe(method_family = none)]
747        pub unsafe fn readFileContentsType_toFile(
748            &self,
749            r#type: Option<&NSPasteboardType>,
750            filename: &NSString,
751        ) -> Option<Retained<NSString>>;
752
753        #[unsafe(method(writeFileWrapper:))]
754        #[unsafe(method_family = none)]
755        pub unsafe fn writeFileWrapper(&self, wrapper: &NSFileWrapper) -> bool;
756
757        #[unsafe(method(readFileWrapper))]
758        #[unsafe(method_family = none)]
759        pub unsafe fn readFileWrapper(&self) -> Option<Retained<NSFileWrapper>>;
760    );
761}
762
763extern "C" {
764    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsfilecontentspboardtype?language=objc)
765    pub static NSFileContentsPboardType: &'static NSPasteboardType;
766}
767
768#[inline]
769pub unsafe extern "C-unwind" fn NSCreateFilenamePboardType(
770    file_type: &NSString,
771) -> Option<Retained<NSPasteboardType>> {
772    extern "C-unwind" {
773        fn NSCreateFilenamePboardType(file_type: &NSString) -> *mut NSPasteboardType;
774    }
775    let ret = unsafe { NSCreateFilenamePboardType(file_type) };
776    unsafe { Retained::from_raw(ret) }
777}
778
779#[inline]
780pub unsafe extern "C-unwind" fn NSCreateFileContentsPboardType(
781    file_type: &NSString,
782) -> Option<Retained<NSPasteboardType>> {
783    extern "C-unwind" {
784        fn NSCreateFileContentsPboardType(file_type: &NSString) -> *mut NSPasteboardType;
785    }
786    let ret = unsafe { NSCreateFileContentsPboardType(file_type) };
787    unsafe { Retained::from_raw(ret) }
788}
789
790#[inline]
791pub unsafe extern "C-unwind" fn NSGetFileType(
792    pboard_type: &NSPasteboardType,
793) -> Option<Retained<NSString>> {
794    extern "C-unwind" {
795        fn NSGetFileType(pboard_type: &NSPasteboardType) -> *mut NSString;
796    }
797    let ret = unsafe { NSGetFileType(pboard_type) };
798    unsafe { Retained::retain_autoreleased(ret) }
799}
800
801#[inline]
802pub unsafe extern "C-unwind" fn NSGetFileTypes(
803    pboard_types: &NSArray<NSPasteboardType>,
804) -> Option<Retained<NSArray<NSString>>> {
805    extern "C-unwind" {
806        fn NSGetFileTypes(pboard_types: &NSArray<NSPasteboardType>) -> *mut NSArray<NSString>;
807    }
808    let ret = unsafe { NSGetFileTypes(pboard_types) };
809    unsafe { Retained::retain_autoreleased(ret) }
810}
811
812extern "C" {
813    /// * Deprecated **
814    ///
815    /// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nsstringpboardtype?language=objc)
816    pub static NSStringPboardType: &'static NSPasteboardType;
817}
818
819extern "C" {
820    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsfilenamespboardtype?language=objc)
821    pub static NSFilenamesPboardType: &'static NSPasteboardType;
822}
823
824extern "C" {
825    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstiffpboardtype?language=objc)
826    pub static NSTIFFPboardType: &'static NSPasteboardType;
827}
828
829extern "C" {
830    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsrtfpboardtype?language=objc)
831    pub static NSRTFPboardType: &'static NSPasteboardType;
832}
833
834extern "C" {
835    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstabulartextpboardtype?language=objc)
836    pub static NSTabularTextPboardType: &'static NSPasteboardType;
837}
838
839extern "C" {
840    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsfontpboardtype?language=objc)
841    pub static NSFontPboardType: &'static NSPasteboardType;
842}
843
844extern "C" {
845    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsrulerpboardtype?language=objc)
846    pub static NSRulerPboardType: &'static NSPasteboardType;
847}
848
849extern "C" {
850    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscolorpboardtype?language=objc)
851    pub static NSColorPboardType: &'static NSPasteboardType;
852}
853
854extern "C" {
855    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsrtfdpboardtype?language=objc)
856    pub static NSRTFDPboardType: &'static NSPasteboardType;
857}
858
859extern "C" {
860    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nshtmlpboardtype?language=objc)
861    pub static NSHTMLPboardType: &'static NSPasteboardType;
862}
863
864extern "C" {
865    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsurlpboardtype?language=objc)
866    pub static NSURLPboardType: &'static NSPasteboardType;
867}
868
869extern "C" {
870    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspdfpboardtype?language=objc)
871    pub static NSPDFPboardType: &'static NSPasteboardType;
872}
873
874extern "C" {
875    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsmultipletextselectionpboardtype?language=objc)
876    pub static NSMultipleTextSelectionPboardType: &'static NSPasteboardType;
877}
878
879extern "C" {
880    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspostscriptpboardtype?language=objc)
881    pub static NSPostScriptPboardType: &'static NSPasteboardType;
882}
883
884extern "C" {
885    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsvcardpboardtype?language=objc)
886    pub static NSVCardPboardType: &'static NSPasteboardType;
887}
888
889extern "C" {
890    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsinktextpboardtype?language=objc)
891    pub static NSInkTextPboardType: &'static NSPasteboardType;
892}
893
894extern "C" {
895    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsfilespromisepboardtype?language=objc)
896    pub static NSFilesPromisePboardType: &'static NSPasteboardType;
897}
898
899extern "C" {
900    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtypefindpanelsearchoptions?language=objc)
901    pub static NSPasteboardTypeFindPanelSearchOptions: &'static NSPasteboardType;
902}
903
904extern "C" {
905    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsgeneralpboard?language=objc)
906    pub static NSGeneralPboard: &'static NSPasteboardName;
907}
908
909extern "C" {
910    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsfontpboard?language=objc)
911    pub static NSFontPboard: &'static NSPasteboardName;
912}
913
914extern "C" {
915    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsrulerpboard?language=objc)
916    pub static NSRulerPboard: &'static NSPasteboardName;
917}
918
919extern "C" {
920    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsfindpboard?language=objc)
921    pub static NSFindPboard: &'static NSPasteboardName;
922}
923
924extern "C" {
925    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsdragpboard?language=objc)
926    pub static NSDragPboard: &'static NSPasteboardName;
927}
928
929extern "C" {
930    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspictpboardtype?language=objc)
931    pub static NSPICTPboardType: &'static NSPasteboardType;
932}