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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
//! 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::*;
use crate::*;
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtype?language=objc)
// NS_TYPED_EXTENSIBLE_ENUM
pub type NSPasteboardType = NSString;
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtypestring?language=objc)
pub static NSPasteboardTypeString: &'static NSPasteboardType;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtypepdf?language=objc)
pub static NSPasteboardTypePDF: &'static NSPasteboardType;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtypetiff?language=objc)
pub static NSPasteboardTypeTIFF: &'static NSPasteboardType;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtypepng?language=objc)
pub static NSPasteboardTypePNG: &'static NSPasteboardType;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtypertf?language=objc)
pub static NSPasteboardTypeRTF: &'static NSPasteboardType;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtypertfd?language=objc)
pub static NSPasteboardTypeRTFD: &'static NSPasteboardType;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtypehtml?language=objc)
pub static NSPasteboardTypeHTML: &'static NSPasteboardType;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtypetabulartext?language=objc)
pub static NSPasteboardTypeTabularText: &'static NSPasteboardType;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtypefont?language=objc)
pub static NSPasteboardTypeFont: &'static NSPasteboardType;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtyperuler?language=objc)
pub static NSPasteboardTypeRuler: &'static NSPasteboardType;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtypecolor?language=objc)
pub static NSPasteboardTypeColor: &'static NSPasteboardType;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtypesound?language=objc)
pub static NSPasteboardTypeSound: &'static NSPasteboardType;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtypemultipletextselection?language=objc)
pub static NSPasteboardTypeMultipleTextSelection: &'static NSPasteboardType;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtypetextfinderoptions?language=objc)
pub static NSPasteboardTypeTextFinderOptions: &'static NSPasteboardType;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtypeurl?language=objc)
pub static NSPasteboardTypeURL: &'static NSPasteboardType;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtypefileurl?language=objc)
pub static NSPasteboardTypeFileURL: &'static NSPasteboardType;
}
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardname?language=objc)
// NS_TYPED_EXTENSIBLE_ENUM
pub type NSPasteboardName = NSString;
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardnamegeneral?language=objc)
pub static NSPasteboardNameGeneral: &'static NSPasteboardName;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardnamefont?language=objc)
pub static NSPasteboardNameFont: &'static NSPasteboardName;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardnameruler?language=objc)
pub static NSPasteboardNameRuler: &'static NSPasteboardName;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardnamefind?language=objc)
pub static NSPasteboardNameFind: &'static NSPasteboardName;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardnamedrag?language=objc)
pub static NSPasteboardNameDrag: &'static NSPasteboardName;
}
/// A value indicating pasteboard access behavior.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardaccessbehavior?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSPasteboardAccessBehavior(pub NSInteger);
impl NSPasteboardAccessBehavior {
/// The default behavior for the General pasteboard is to ask upon programmatic access. All other pasteboards default to always allow access.
/// 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.
/// 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`.
#[doc(alias = "NSPasteboardAccessBehaviorDefault")]
pub const Default: Self = Self(0);
/// 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.
#[doc(alias = "NSPasteboardAccessBehaviorAsk")]
pub const Ask: Self = Self(1);
/// The system will automatically allow all pasteboard access, without notifying the user. The app is listed in the corresponding System Settings pane.
#[doc(alias = "NSPasteboardAccessBehaviorAlwaysAllow")]
pub const AlwaysAllow: Self = Self(2);
/// 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.
#[doc(alias = "NSPasteboardAccessBehaviorAlwaysDeny")]
pub const AlwaysDeny: Self = Self(3);
}
unsafe impl Encode for NSPasteboardAccessBehavior {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for NSPasteboardAccessBehavior {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
/// A pattern to detect on the pasteboard, such as a URL, text, or a number.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboarddetectionpattern?language=objc)
// NS_TYPED_ENUM
pub type NSPasteboardDetectionPattern = NSString;
extern "C" {
/// A pattern that indicates the pasteboard detects a string that consists of a web URL.
///
/// Returns: NSString value, suitable for implementing "Paste and Go"
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboarddetectionpatternprobableweburl?language=objc)
pub static NSPasteboardDetectionPatternProbableWebURL: &'static NSPasteboardDetectionPattern;
}
extern "C" {
/// A pattern that indicates the pasteboard detects a string suitable for use as a web search term.
///
/// Returns: NSString value, suitable for implementing "Paste and Search"
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboarddetectionpatternprobablewebsearch?language=objc)
pub static NSPasteboardDetectionPatternProbableWebSearch: &'static NSPasteboardDetectionPattern;
}
extern "C" {
/// A pattern that indicates the pasteboard detects a string that consists of a numeric value.
///
/// Returns: NSNumber value
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboarddetectionpatternnumber?language=objc)
pub static NSPasteboardDetectionPatternNumber: &'static NSPasteboardDetectionPattern;
}
extern "C" {
/// A pattern that indicates the pasteboard detects a string that contains a URL.
///
/// Returns: array of DDMatchLink values
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboarddetectionpatternlink?language=objc)
pub static NSPasteboardDetectionPatternLink: &'static NSPasteboardDetectionPattern;
}
extern "C" {
/// A pattern that indicates the pasteboard detects a string that contains a phone number.
///
/// Returns: array of DDMatchPhoneNumber values
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboarddetectionpatternphonenumber?language=objc)
pub static NSPasteboardDetectionPatternPhoneNumber: &'static NSPasteboardDetectionPattern;
}
extern "C" {
/// A pattern that indicates the pasteboard detects a string that contains an email address.
///
/// Returns: array of DDMatchEmailAddress values
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboarddetectionpatternemailaddress?language=objc)
pub static NSPasteboardDetectionPatternEmailAddress: &'static NSPasteboardDetectionPattern;
}
extern "C" {
/// A pattern that indicates the pasteboard detects a string that contains a postal address.
///
/// Returns: array of DDMatchPostalAddress values
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboarddetectionpatternpostaladdress?language=objc)
pub static NSPasteboardDetectionPatternPostalAddress: &'static NSPasteboardDetectionPattern;
}
extern "C" {
/// A pattern that indicates the pasteboard detects a string that contains a calendar event.
///
/// Returns: array of DDMatchCalendarEvent values
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboarddetectionpatterncalendarevent?language=objc)
pub static NSPasteboardDetectionPatternCalendarEvent: &'static NSPasteboardDetectionPattern;
}
extern "C" {
/// A pattern that indicates the pasteboard detects a string that contains a parcel tracking number and carrier.
///
/// Returns: array of DDMatchShipmentTrackingNumber values
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboarddetectionpatternshipmenttrackingnumber?language=objc)
pub static NSPasteboardDetectionPatternShipmentTrackingNumber:
&'static NSPasteboardDetectionPattern;
}
extern "C" {
/// A pattern that indicates the pasteboard detects a string that contains a flight number.
///
/// Returns: array of DDMatchFlightNumber values
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboarddetectionpatternflightnumber?language=objc)
pub static NSPasteboardDetectionPatternFlightNumber: &'static NSPasteboardDetectionPattern;
}
extern "C" {
/// A pattern that indicates the pasteboard detects a string that contains an amount of money.
///
/// Returns: array of DDMatchMoneyAmount values
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboarddetectionpatternmoneyamount?language=objc)
pub static NSPasteboardDetectionPatternMoneyAmount: &'static NSPasteboardDetectionPattern;
}
/// A metadata type to detect on the pasteboard.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardmetadatatype?language=objc)
// NS_TYPED_ENUM
pub type NSPasteboardMetadataType = NSString;
extern "C" {
/// A metadata type that returns the content type if the pasteboard detects a reference to a file.
///
/// Returns: UTType value for the detected content type of the file URL, if a file URL type is present.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardmetadatatypecontenttype?language=objc)
pub static NSPasteboardMetadataTypeContentType: &'static NSPasteboardMetadataType;
}
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardcontentsoptions?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSPasteboardContentsOptions(pub NSUInteger);
bitflags::bitflags! {
impl NSPasteboardContentsOptions: NSUInteger {
#[doc(alias = "NSPasteboardContentsCurrentHostOnly")]
const CurrentHostOnly = 1<<0;
}
}
unsafe impl Encode for NSPasteboardContentsOptions {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for NSPasteboardContentsOptions {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardreadingoptionkey?language=objc)
// NS_TYPED_ENUM
pub type NSPasteboardReadingOptionKey = NSString;
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardurlreadingfileurlsonlykey?language=objc)
pub static NSPasteboardURLReadingFileURLsOnlyKey: &'static NSPasteboardReadingOptionKey;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardurlreadingcontentsconformtotypeskey?language=objc)
pub static NSPasteboardURLReadingContentsConformToTypesKey:
&'static NSPasteboardReadingOptionKey;
}
extern_class!(
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboard?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct NSPasteboard;
);
extern_conformance!(
unsafe impl NSObjectProtocol for NSPasteboard {}
);
impl NSPasteboard {
extern_methods!(
#[unsafe(method(generalPasteboard))]
#[unsafe(method_family = none)]
pub fn generalPasteboard() -> Retained<NSPasteboard>;
#[unsafe(method(pasteboardWithName:))]
#[unsafe(method_family = none)]
pub fn pasteboardWithName(name: &NSPasteboardName) -> Retained<NSPasteboard>;
#[unsafe(method(pasteboardWithUniqueName))]
#[unsafe(method_family = none)]
pub fn pasteboardWithUniqueName() -> Retained<NSPasteboard>;
#[unsafe(method(name))]
#[unsafe(method_family = none)]
pub fn name(&self) -> Retained<NSPasteboardName>;
#[unsafe(method(changeCount))]
#[unsafe(method_family = none)]
pub fn changeCount(&self) -> NSInteger;
/// 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.
#[unsafe(method(accessBehavior))]
#[unsafe(method_family = none)]
pub fn accessBehavior(&self) -> NSPasteboardAccessBehavior;
#[unsafe(method(prepareForNewContentsWithOptions:))]
#[unsafe(method_family = none)]
pub fn prepareForNewContentsWithOptions(
&self,
options: NSPasteboardContentsOptions,
) -> NSInteger;
#[unsafe(method(clearContents))]
#[unsafe(method_family = none)]
pub fn clearContents(&self) -> NSInteger;
#[unsafe(method(writeObjects:))]
#[unsafe(method_family = none)]
pub fn writeObjects(
&self,
objects: &NSArray<ProtocolObject<dyn NSPasteboardWriting>>,
) -> bool;
/// # Safety
///
/// - `class_array` generic probably has further requirements.
/// - `options` generic should be of the correct type.
#[unsafe(method(readObjectsForClasses:options:))]
#[unsafe(method_family = none)]
pub unsafe fn readObjectsForClasses_options(
&self,
class_array: &NSArray<AnyClass>,
options: Option<&NSDictionary<NSPasteboardReadingOptionKey, AnyObject>>,
) -> Option<Retained<NSArray>>;
#[cfg(feature = "NSPasteboardItem")]
#[unsafe(method(pasteboardItems))]
#[unsafe(method_family = none)]
pub fn pasteboardItems(&self) -> Option<Retained<NSArray<NSPasteboardItem>>>;
#[cfg(feature = "NSPasteboardItem")]
#[unsafe(method(indexOfPasteboardItem:))]
#[unsafe(method_family = none)]
pub fn indexOfPasteboardItem(&self, pasteboard_item: &NSPasteboardItem) -> NSUInteger;
#[unsafe(method(canReadItemWithDataConformingToTypes:))]
#[unsafe(method_family = none)]
pub fn canReadItemWithDataConformingToTypes(&self, types: &NSArray<NSString>) -> bool;
/// # Safety
///
/// - `class_array` generic probably has further requirements.
/// - `options` generic should be of the correct type.
#[unsafe(method(canReadObjectForClasses:options:))]
#[unsafe(method_family = none)]
pub unsafe fn canReadObjectForClasses_options(
&self,
class_array: &NSArray<AnyClass>,
options: Option<&NSDictionary<NSPasteboardReadingOptionKey, AnyObject>>,
) -> bool;
/// # Safety
///
/// `new_owner` should be of the correct type.
#[unsafe(method(declareTypes:owner:))]
#[unsafe(method_family = none)]
pub unsafe fn declareTypes_owner(
&self,
new_types: &NSArray<NSPasteboardType>,
new_owner: Option<&AnyObject>,
) -> NSInteger;
/// # Safety
///
/// `new_owner` should be of the correct type.
#[unsafe(method(addTypes:owner:))]
#[unsafe(method_family = none)]
pub unsafe fn addTypes_owner(
&self,
new_types: &NSArray<NSPasteboardType>,
new_owner: Option<&AnyObject>,
) -> NSInteger;
#[unsafe(method(types))]
#[unsafe(method_family = none)]
pub fn types(&self) -> Option<Retained<NSArray<NSPasteboardType>>>;
#[unsafe(method(availableTypeFromArray:))]
#[unsafe(method_family = none)]
pub fn availableTypeFromArray(
&self,
types: &NSArray<NSPasteboardType>,
) -> Option<Retained<NSPasteboardType>>;
#[unsafe(method(setData:forType:))]
#[unsafe(method_family = none)]
pub fn setData_forType(&self, data: Option<&NSData>, data_type: &NSPasteboardType) -> bool;
/// # Safety
///
/// `plist` should be of the correct type.
#[unsafe(method(setPropertyList:forType:))]
#[unsafe(method_family = none)]
pub unsafe fn setPropertyList_forType(
&self,
plist: &AnyObject,
data_type: &NSPasteboardType,
) -> bool;
#[unsafe(method(setString:forType:))]
#[unsafe(method_family = none)]
pub fn setString_forType(&self, string: &NSString, data_type: &NSPasteboardType) -> bool;
#[unsafe(method(dataForType:))]
#[unsafe(method_family = none)]
pub fn dataForType(&self, data_type: &NSPasteboardType) -> Option<Retained<NSData>>;
#[unsafe(method(propertyListForType:))]
#[unsafe(method_family = none)]
pub fn propertyListForType(
&self,
data_type: &NSPasteboardType,
) -> Option<Retained<AnyObject>>;
#[unsafe(method(stringForType:))]
#[unsafe(method_family = none)]
pub fn stringForType(&self, data_type: &NSPasteboardType) -> Option<Retained<NSString>>;
#[cfg(feature = "block2")]
/// Determines whether the first pasteboard item matches the specified patterns, without notifying the person using the app.
///
/// This method only gives an indication of whether the first pasteboard item matches a particular pattern, and doesn’t allow the app to access the item's contents. As a result, the system doesn’t notify the person using the app about reading the contents of the pasteboard.
///
/// The following example shows how to use this method to find email and postal addresses in the first pasteboard item:
///
/// ```obj-c
/// [NSPasteboard.generalPasteboard
/// detectPatternsForPatterns:[NSSet setWithArray:
/// @
/// [NSPasteboardDetectionPatternEmailAddress,
/// NSPasteboardDetectionPatternPostalAddress]]
/// completionHandler:^(NSSet
/// <NSPasteboardDetectionPattern
/// > *matchedPatterns, NSError *error) {
/// if (error) {
/// NSLog(
/// "
/// Error: %
/// "
/// , error);
/// return;
/// }
/// BOOL matchedEmail = [matchedPatterns containsObject:NSPasteboardDetectionPatternEmailAddress];
/// BOOL matchedPostal = [matchedPatterns containsObject: NSPasteboardDetectionPatternPostalAddress];
/// if (matchedEmail) {
/// NSLog(
/// "
/// Email address(es) detected");
/// }
/// if (matchedPostal) {
/// NSLog(
/// "
/// Postal address(es) detected");
/// }
/// if (!matchedEmail
/// &
/// &
/// !matchedPostal) {
/// NSLog(
/// "
/// Matched neither email nor postal addresses.");
/// }
/// }];
/// ```
///
/// - Parameters:
/// - patterns: The patterns to detect on the pasteboard.
/// - completionHandler: A block the system invokes after detecting patterns on the pasteboard. The block receives either a set with the patterns the system finds on the pasteboard or an error if detection fails.
#[unsafe(method(detectPatternsForPatterns:completionHandler:))]
#[unsafe(method_family = none)]
pub fn detectPatternsForPatterns_completionHandler(
&self,
patterns: &NSSet<NSPasteboardDetectionPattern>,
completion_handler: &block2::DynBlock<
dyn Fn(*mut NSSet<NSPasteboardDetectionPattern>, *mut NSError),
>,
);
#[cfg(feature = "block2")]
/// Determines whether the first pasteboard item matches the specified patterns, reading the contents if it finds a match.
///
/// For details about the types returned for each pattern, see ``NSPasteboardDetectionPattern``.
///
/// The following example shows how to use this method to find web URLs and web search terms in the first pasteboard item:
///
/// ```obj-c
/// [NSPasteboard.generalPasteboard
/// detectValuesForPatterns:[NSSet setWithArray:
/// @
/// [NSPasteboardDetectionPatternProbableWebSearch,
/// NSPasteboardDetectionPatternProbableWebURL]]
/// completionHandler:^(NSDictionary
/// <NSPasteboardDetectionPattern
/// , id> *patternValues, NSError *error) {
/// if (error) {
/// NSLog(
/// "
/// Error: %
/// "
/// , error);
/// return;
/// }
/// NSString *searchString = (NSString*)patternValues[NSPasteboardDetectionPatternProbableWebSearch];
/// NSString *urlString = (NSString*)patternValues[NSPasteboardDetectionPatternProbableWebURL] ;
/// if (searchString != nil) {
/// NSLog(
/// "
/// Web search retrieved: %
/// "
/// , searchString);
/// }
/// if (urlString != nil) {
/// NSLog(
/// "
/// Web URL retrieved: %
/// "
/// , urlString);
/// }
/// if (searchString == nil
/// &
/// &
/// urlString == nil) {
/// NSLog(
/// "
/// No web patterns retrieved.");
/// }
/// }];
/// ```
///
/// > Important: If the system finds a match when calling this method, the system informs the person using the app that the app is trying to read the contents of the pasteboard. If the person denies access to the pasteboard, the completion handler receives an error.
///
/// - Parameters:
/// - patterns: The patterns to detect on the pasteboard.
/// - completionHandler: A block the system invokes after detecting patterns on the pasteboard. The block returns either a dictionary with the patterns the system finds on the pasteboard or an error if detection fails. The dictionary keys specify the matched patterns and the values specify the corresponding content of the pasteboard.
#[unsafe(method(detectValuesForPatterns:completionHandler:))]
#[unsafe(method_family = none)]
pub fn detectValuesForPatterns_completionHandler(
&self,
patterns: &NSSet<NSPasteboardDetectionPattern>,
completion_handler: &block2::DynBlock<
dyn Fn(*mut NSDictionary<NSPasteboardDetectionPattern, AnyObject>, *mut NSError),
>,
);
#[cfg(feature = "block2")]
/// Determines available metadata from the specified metadata types for the first pasteboard item, without notifying the person using the app.
///
/// This method only gives access to limited types of metadata and doesn’t allow the app to access the contents. As a result, the system doesn’t notify the person using the app about reading the contents of the pasteboard.
///
/// For details about the metadata returned for each type, see ``NSPasteboardMetadataType``.
///
/// The following example shows how to use this method to find the content type of a file reference in the first item on the pasteboard:
///
/// ```obj-c
/// [NSPasteboard.generalPasteboard
/// detectMetadataForTypes:[NSSet setWithArray:
/// @
/// [NSPasteboardMetadataTypeContentType]]
/// completionHandler:^(NSDictionary
/// <NSPasteboardMetadataType
/// , id> *metadata, NSError *error) {
/// if (error) {
/// NSLog(
/// "
/// Error: %
/// "
/// , error);
/// return;
/// }
/// UTType *contentType = (UTType*)metadata[NSPasteboardMetadataTypeContentType];
/// if (contentType) {
/// NSLog(
/// "
/// Content type is: %
/// "
/// , contentType.identifier);
/// } else {
/// NSLog(
/// "
/// Couldn't get content type");
/// }
/// }];
/// ```
///
/// - Parameters:
/// - types: The metadata types to detect on the pasteboard.
/// - completionHandler: A block the system invokes after detecting metadata on the pasteboard. The block receives either a dictionary with the metadata types the system finds on the pasteboard or an error if detection fails. The dictionary keys specify the matched metadata types and the values specify the corresponding metadata.
#[unsafe(method(detectMetadataForTypes:completionHandler:))]
#[unsafe(method_family = none)]
pub fn detectMetadataForTypes_completionHandler(
&self,
types: &NSSet<NSPasteboardMetadataType>,
completion_handler: &block2::DynBlock<
dyn Fn(*mut NSDictionary<NSPasteboardMetadataType, AnyObject>, *mut NSError),
>,
);
);
}
/// Methods declared on superclass `NSObject`.
impl NSPasteboard {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub fn new() -> Retained<Self>;
);
}
impl DefaultRetained for NSPasteboard {
#[inline]
fn default_retained() -> Retained<Self> {
Self::new()
}
}
/// FilterServices.
impl NSPasteboard {
extern_methods!(
#[unsafe(method(typesFilterableTo:))]
#[unsafe(method_family = none)]
pub fn typesFilterableTo(r#type: &NSPasteboardType) -> Retained<NSArray<NSPasteboardType>>;
#[unsafe(method(pasteboardByFilteringFile:))]
#[unsafe(method_family = none)]
pub fn pasteboardByFilteringFile(filename: &NSString) -> Retained<NSPasteboard>;
#[unsafe(method(pasteboardByFilteringData:ofType:))]
#[unsafe(method_family = none)]
pub fn pasteboardByFilteringData_ofType(
data: &NSData,
r#type: &NSPasteboardType,
) -> Retained<NSPasteboard>;
#[unsafe(method(pasteboardByFilteringTypesInPasteboard:))]
#[unsafe(method_family = none)]
pub fn pasteboardByFilteringTypesInPasteboard(
pboard: &NSPasteboard,
) -> Retained<NSPasteboard>;
);
}
extern_protocol!(
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtypeowner?language=objc)
pub unsafe trait NSPasteboardTypeOwner: NSObjectProtocol {
#[unsafe(method(pasteboard:provideDataForType:))]
#[unsafe(method_family = none)]
fn pasteboard_provideDataForType(&self, sender: &NSPasteboard, r#type: &NSPasteboardType);
#[optional]
#[unsafe(method(pasteboardChangedOwner:))]
#[unsafe(method_family = none)]
fn pasteboardChangedOwner(&self, sender: &NSPasteboard);
}
);
/// * NSPasteboardWriting and NSPasteboardReading Protocols **
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardwritingoptions?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSPasteboardWritingOptions(pub NSUInteger);
bitflags::bitflags! {
impl NSPasteboardWritingOptions: NSUInteger {
#[doc(alias = "NSPasteboardWritingPromised")]
const Promised = 1<<9;
}
}
unsafe impl Encode for NSPasteboardWritingOptions {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for NSPasteboardWritingOptions {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_protocol!(
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardwriting?language=objc)
pub unsafe trait NSPasteboardWriting: NSObjectProtocol {
#[unsafe(method(writableTypesForPasteboard:))]
#[unsafe(method_family = none)]
fn writableTypesForPasteboard(
&self,
pasteboard: &NSPasteboard,
) -> Retained<NSArray<NSPasteboardType>>;
#[optional]
#[unsafe(method(writingOptionsForType:pasteboard:))]
#[unsafe(method_family = none)]
fn writingOptionsForType_pasteboard(
&self,
r#type: &NSPasteboardType,
pasteboard: &NSPasteboard,
) -> NSPasteboardWritingOptions;
#[unsafe(method(pasteboardPropertyListForType:))]
#[unsafe(method_family = none)]
fn pasteboardPropertyListForType(
&self,
r#type: &NSPasteboardType,
) -> Option<Retained<AnyObject>>;
}
);
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardreadingoptions?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSPasteboardReadingOptions(pub NSUInteger);
bitflags::bitflags! {
impl NSPasteboardReadingOptions: NSUInteger {
#[doc(alias = "NSPasteboardReadingAsData")]
const AsData = 0;
#[doc(alias = "NSPasteboardReadingAsString")]
const AsString = 1<<0;
#[doc(alias = "NSPasteboardReadingAsPropertyList")]
const AsPropertyList = 1<<1;
#[doc(alias = "NSPasteboardReadingAsKeyedArchive")]
const AsKeyedArchive = 1<<2;
}
}
unsafe impl Encode for NSPasteboardReadingOptions {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for NSPasteboardReadingOptions {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_protocol!(
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardreading?language=objc)
pub unsafe trait NSPasteboardReading: NSObjectProtocol {
#[unsafe(method(readableTypesForPasteboard:))]
#[unsafe(method_family = none)]
fn readableTypesForPasteboard(
pasteboard: &NSPasteboard,
) -> Retained<NSArray<NSPasteboardType>>;
#[optional]
#[unsafe(method(readingOptionsForType:pasteboard:))]
#[unsafe(method_family = none)]
fn readingOptionsForType_pasteboard(
r#type: &NSPasteboardType,
pasteboard: &NSPasteboard,
) -> NSPasteboardReadingOptions;
/// # Safety
///
/// `property_list` should be of the correct type.
#[optional]
#[unsafe(method(initWithPasteboardPropertyList:ofType:))]
#[unsafe(method_family = init)]
unsafe fn initWithPasteboardPropertyList_ofType(
this: Allocated<Self>,
property_list: &AnyObject,
r#type: &NSPasteboardType,
) -> Option<Retained<Self>>;
}
);
mod private_NSURLNSPasteboardSupport {
pub trait Sealed {}
}
/// Category "NSPasteboardSupport" on [`NSURL`].
#[doc(alias = "NSPasteboardSupport")]
pub unsafe trait NSURLNSPasteboardSupport:
ClassType + Sized + private_NSURLNSPasteboardSupport::Sealed
{
extern_methods!(
#[unsafe(method(URLFromPasteboard:))]
#[unsafe(method_family = none)]
fn URLFromPasteboard(paste_board: &NSPasteboard) -> Option<Retained<NSURL>>;
#[unsafe(method(writeToPasteboard:))]
#[unsafe(method_family = none)]
fn writeToPasteboard(&self, paste_board: &NSPasteboard);
);
}
impl private_NSURLNSPasteboardSupport::Sealed for NSURL {}
unsafe impl NSURLNSPasteboardSupport for NSURL {}
extern_conformance!(
unsafe impl NSPasteboardReading for NSURL {}
);
extern_conformance!(
unsafe impl NSPasteboardWriting for NSURL {}
);
extern_conformance!(
unsafe impl NSPasteboardReading for NSString {}
);
extern_conformance!(
unsafe impl NSPasteboardWriting for NSString {}
);
/// NSFileContents.
///
/// * File Contents **
impl NSPasteboard {
extern_methods!(
#[unsafe(method(writeFileContents:))]
#[unsafe(method_family = none)]
pub fn writeFileContents(&self, filename: &NSString) -> bool;
#[unsafe(method(readFileContentsType:toFile:))]
#[unsafe(method_family = none)]
pub fn readFileContentsType_toFile(
&self,
r#type: Option<&NSPasteboardType>,
filename: &NSString,
) -> Option<Retained<NSString>>;
#[unsafe(method(writeFileWrapper:))]
#[unsafe(method_family = none)]
pub fn writeFileWrapper(&self, wrapper: &NSFileWrapper) -> bool;
#[unsafe(method(readFileWrapper))]
#[unsafe(method_family = none)]
pub fn readFileWrapper(&self) -> Option<Retained<NSFileWrapper>>;
);
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsfilecontentspboardtype?language=objc)
pub static NSFileContentsPboardType: &'static NSPasteboardType;
}
#[inline]
pub extern "C-unwind" fn NSCreateFilenamePboardType(
file_type: &NSString,
) -> Option<Retained<NSPasteboardType>> {
extern "C-unwind" {
fn NSCreateFilenamePboardType(file_type: &NSString) -> *mut NSPasteboardType;
}
let ret = unsafe { NSCreateFilenamePboardType(file_type) };
unsafe { Retained::from_raw(ret) }
}
#[inline]
pub extern "C-unwind" fn NSCreateFileContentsPboardType(
file_type: &NSString,
) -> Option<Retained<NSPasteboardType>> {
extern "C-unwind" {
fn NSCreateFileContentsPboardType(file_type: &NSString) -> *mut NSPasteboardType;
}
let ret = unsafe { NSCreateFileContentsPboardType(file_type) };
unsafe { Retained::from_raw(ret) }
}
#[inline]
pub extern "C-unwind" fn NSGetFileType(
pboard_type: &NSPasteboardType,
) -> Option<Retained<NSString>> {
extern "C-unwind" {
fn NSGetFileType(pboard_type: &NSPasteboardType) -> *mut NSString;
}
let ret = unsafe { NSGetFileType(pboard_type) };
unsafe { Retained::retain_autoreleased(ret) }
}
#[inline]
pub extern "C-unwind" fn NSGetFileTypes(
pboard_types: &NSArray<NSPasteboardType>,
) -> Option<Retained<NSArray<NSString>>> {
extern "C-unwind" {
fn NSGetFileTypes(pboard_types: &NSArray<NSPasteboardType>) -> *mut NSArray<NSString>;
}
let ret = unsafe { NSGetFileTypes(pboard_types) };
unsafe { Retained::retain_autoreleased(ret) }
}
extern "C" {
/// * Deprecated **
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nsstringpboardtype?language=objc)
#[deprecated]
pub static NSStringPboardType: &'static NSPasteboardType;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsfilenamespboardtype?language=objc)
#[deprecated = "Create multiple pasteboard items with NSPasteboardTypeFileURL or kUTTypeFileURL instead"]
pub static NSFilenamesPboardType: &'static NSPasteboardType;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstiffpboardtype?language=objc)
#[deprecated]
pub static NSTIFFPboardType: &'static NSPasteboardType;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsrtfpboardtype?language=objc)
#[deprecated]
pub static NSRTFPboardType: &'static NSPasteboardType;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstabulartextpboardtype?language=objc)
#[deprecated]
pub static NSTabularTextPboardType: &'static NSPasteboardType;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsfontpboardtype?language=objc)
#[deprecated]
pub static NSFontPboardType: &'static NSPasteboardType;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsrulerpboardtype?language=objc)
#[deprecated]
pub static NSRulerPboardType: &'static NSPasteboardType;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscolorpboardtype?language=objc)
#[deprecated]
pub static NSColorPboardType: &'static NSPasteboardType;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsrtfdpboardtype?language=objc)
#[deprecated]
pub static NSRTFDPboardType: &'static NSPasteboardType;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nshtmlpboardtype?language=objc)
#[deprecated]
pub static NSHTMLPboardType: &'static NSPasteboardType;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsurlpboardtype?language=objc)
#[deprecated]
pub static NSURLPboardType: &'static NSPasteboardType;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspdfpboardtype?language=objc)
#[deprecated]
pub static NSPDFPboardType: &'static NSPasteboardType;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsmultipletextselectionpboardtype?language=objc)
#[deprecated]
pub static NSMultipleTextSelectionPboardType: &'static NSPasteboardType;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspostscriptpboardtype?language=objc)
#[deprecated]
pub static NSPostScriptPboardType: &'static NSPasteboardType;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsvcardpboardtype?language=objc)
#[deprecated]
pub static NSVCardPboardType: &'static NSPasteboardType;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsinktextpboardtype?language=objc)
#[deprecated]
pub static NSInkTextPboardType: &'static NSPasteboardType;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsfilespromisepboardtype?language=objc)
#[deprecated]
pub static NSFilesPromisePboardType: &'static NSPasteboardType;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtypefindpanelsearchoptions?language=objc)
#[deprecated]
pub static NSPasteboardTypeFindPanelSearchOptions: &'static NSPasteboardType;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsgeneralpboard?language=objc)
#[deprecated]
pub static NSGeneralPboard: &'static NSPasteboardName;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsfontpboard?language=objc)
#[deprecated]
pub static NSFontPboard: &'static NSPasteboardName;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsrulerpboard?language=objc)
#[deprecated]
pub static NSRulerPboard: &'static NSPasteboardName;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsfindpboard?language=objc)
#[deprecated]
pub static NSFindPboard: &'static NSPasteboardName;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsdragpboard?language=objc)
#[deprecated]
pub static NSDragPboard: &'static NSPasteboardName;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspictpboardtype?language=objc)
#[deprecated]
pub static NSPICTPboardType: &'static NSPasteboardType;
}