objc2_app_kit/generated/
NSPasteboardItem.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
10extern_class!(
11    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboarditem?language=objc)
12    #[unsafe(super(NSObject))]
13    #[derive(Debug, PartialEq, Eq, Hash)]
14    pub struct NSPasteboardItem;
15);
16
17extern_conformance!(
18    unsafe impl NSObjectProtocol for NSPasteboardItem {}
19);
20
21#[cfg(feature = "NSPasteboard")]
22extern_conformance!(
23    unsafe impl NSPasteboardReading for NSPasteboardItem {}
24);
25
26#[cfg(feature = "NSPasteboard")]
27extern_conformance!(
28    unsafe impl NSPasteboardWriting for NSPasteboardItem {}
29);
30
31impl NSPasteboardItem {
32    extern_methods!(
33        #[cfg(feature = "NSPasteboard")]
34        #[unsafe(method(types))]
35        #[unsafe(method_family = none)]
36        pub unsafe fn types(&self) -> Retained<NSArray<NSPasteboardType>>;
37
38        #[cfg(feature = "NSPasteboard")]
39        #[unsafe(method(availableTypeFromArray:))]
40        #[unsafe(method_family = none)]
41        pub unsafe fn availableTypeFromArray(
42            &self,
43            types: &NSArray<NSPasteboardType>,
44        ) -> Option<Retained<NSPasteboardType>>;
45
46        #[cfg(feature = "NSPasteboard")]
47        #[unsafe(method(setDataProvider:forTypes:))]
48        #[unsafe(method_family = none)]
49        pub unsafe fn setDataProvider_forTypes(
50            &self,
51            data_provider: &ProtocolObject<dyn NSPasteboardItemDataProvider>,
52            types: &NSArray<NSPasteboardType>,
53        ) -> bool;
54
55        #[cfg(feature = "NSPasteboard")]
56        #[unsafe(method(setData:forType:))]
57        #[unsafe(method_family = none)]
58        pub unsafe fn setData_forType(&self, data: &NSData, r#type: &NSPasteboardType) -> bool;
59
60        #[cfg(feature = "NSPasteboard")]
61        #[unsafe(method(setString:forType:))]
62        #[unsafe(method_family = none)]
63        pub unsafe fn setString_forType(
64            &self,
65            string: &NSString,
66            r#type: &NSPasteboardType,
67        ) -> bool;
68
69        #[cfg(feature = "NSPasteboard")]
70        #[unsafe(method(setPropertyList:forType:))]
71        #[unsafe(method_family = none)]
72        pub unsafe fn setPropertyList_forType(
73            &self,
74            property_list: &AnyObject,
75            r#type: &NSPasteboardType,
76        ) -> bool;
77
78        #[cfg(feature = "NSPasteboard")]
79        #[unsafe(method(dataForType:))]
80        #[unsafe(method_family = none)]
81        pub unsafe fn dataForType(&self, r#type: &NSPasteboardType) -> Option<Retained<NSData>>;
82
83        #[cfg(feature = "NSPasteboard")]
84        #[unsafe(method(stringForType:))]
85        #[unsafe(method_family = none)]
86        pub unsafe fn stringForType(&self, r#type: &NSPasteboardType)
87            -> Option<Retained<NSString>>;
88
89        #[cfg(feature = "NSPasteboard")]
90        #[unsafe(method(propertyListForType:))]
91        #[unsafe(method_family = none)]
92        pub unsafe fn propertyListForType(
93            &self,
94            r#type: &NSPasteboardType,
95        ) -> Option<Retained<AnyObject>>;
96
97        #[cfg(all(feature = "NSPasteboard", feature = "block2"))]
98        /// Determines whether this pasteboard item matches the specified patterns, without notifying the user.
99        ///
100        /// 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.
101        ///
102        ///
103        /// Parameter `patterns`: The patterns to detect on the pasteboard item.
104        ///
105        /// Parameter `completionHandler`: A block that the system invokes after detecting patterns on the pasteboard item. The block receives either a set with the patterns found on the pasteboard item or an error if detection failed.
106        #[unsafe(method(detectPatternsForPatterns:completionHandler:))]
107        #[unsafe(method_family = none)]
108        pub unsafe fn detectPatternsForPatterns_completionHandler(
109            &self,
110            patterns: &NSSet<NSPasteboardDetectionPattern>,
111            completion_handler: &block2::DynBlock<
112                dyn Fn(*mut NSSet<NSPasteboardDetectionPattern>, *mut NSError),
113            >,
114        );
115
116        #[cfg(all(feature = "NSPasteboard", feature = "block2"))]
117        /// Determines whether this pasteboard item matches the specified patterns, reading the contents if it finds a match.
118        ///
119        /// - Important: Calling this method notifies the user that the app has read the contents of the pasteboard, if a match is found.
120        ///
121        /// For details about the types returned for each pattern, see `NSPasteboardDetectionPattern`.
122        ///
123        ///
124        /// Parameter `patterns`: The patterns to detect on the pasteboard item.
125        ///
126        /// Parameter `completionHandler`: A block that the system invokes after detecting patterns on the pasteboard item. The block returns either dictionary with the patterns found on the pasteboard item or an error if detection failed. The dictionary keys specify the matched patterns, and the values specify the corresponding content of the pasteboard.
127        #[unsafe(method(detectValuesForPatterns:completionHandler:))]
128        #[unsafe(method_family = none)]
129        pub unsafe fn detectValuesForPatterns_completionHandler(
130            &self,
131            patterns: &NSSet<NSPasteboardDetectionPattern>,
132            completion_handler: &block2::DynBlock<
133                dyn Fn(*mut NSDictionary<NSPasteboardDetectionPattern, AnyObject>, *mut NSError),
134            >,
135        );
136
137        #[cfg(all(feature = "NSPasteboard", feature = "block2"))]
138        /// Determines available metadata from the specified metadata types for this pasteboard item, without notifying the user.
139        ///
140        /// 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.
141        ///
142        /// For details about the metadata returned for each type, see `NSPasteboardMetadataType`.
143        ///
144        ///
145        /// Parameter `types`: The metadata types to detect on the pasteboard item.
146        ///
147        /// Parameter `completionHandler`: A block that the system invokes after detecting metadata on the pasteboard item. The block receives either a dictionary with the metadata types found on the pasteboard item or an error if detection failed. The dictionary keys specify the matched metadata types, and the values specify the corresponding metadata.
148        #[unsafe(method(detectMetadataForTypes:completionHandler:))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn detectMetadataForTypes_completionHandler(
151            &self,
152            types: &NSSet<NSPasteboardMetadataType>,
153            completion_handler: &block2::DynBlock<
154                dyn Fn(*mut NSDictionary<NSPasteboardMetadataType, AnyObject>, *mut NSError),
155            >,
156        );
157    );
158}
159
160/// Methods declared on superclass `NSObject`.
161impl NSPasteboardItem {
162    extern_methods!(
163        #[unsafe(method(init))]
164        #[unsafe(method_family = init)]
165        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
166
167        #[unsafe(method(new))]
168        #[unsafe(method_family = new)]
169        pub unsafe fn new() -> Retained<Self>;
170    );
171}
172
173extern_protocol!(
174    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboarditemdataprovider?language=objc)
175    pub unsafe trait NSPasteboardItemDataProvider: NSObjectProtocol {
176        #[cfg(feature = "NSPasteboard")]
177        #[unsafe(method(pasteboard:item:provideDataForType:))]
178        #[unsafe(method_family = none)]
179        unsafe fn pasteboard_item_provideDataForType(
180            &self,
181            pasteboard: Option<&NSPasteboard>,
182            item: &NSPasteboardItem,
183            r#type: &NSPasteboardType,
184        );
185
186        #[cfg(feature = "NSPasteboard")]
187        #[optional]
188        #[unsafe(method(pasteboardFinishedWithDataProvider:))]
189        #[unsafe(method_family = none)]
190        unsafe fn pasteboardFinishedWithDataProvider(&self, pasteboard: &NSPasteboard);
191    }
192);