objc2_application_services/generated/HIServices/
Pasteboard.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "objc2")]
8use objc2::__framework_prelude::*;
9use objc2_core_foundation::*;
10
11use crate::*;
12
13/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/pasteboard?language=objc)
14#[doc(alias = "PasteboardRef")]
15#[repr(C)]
16pub struct Pasteboard {
17    inner: [u8; 0],
18    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
19}
20
21cf_type!(
22    unsafe impl Pasteboard {}
23);
24#[cfg(feature = "objc2")]
25cf_objc2_type!(
26    unsafe impl RefEncode<"OpaquePasteboardRef"> for Pasteboard {}
27);
28
29/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/pasteboarditemid?language=objc)
30pub type PasteboardItemID = *mut c_void;
31
32/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/badpasteboardsyncerr?language=objc)
33pub const badPasteboardSyncErr: c_int = -25130;
34/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/badpasteboardindexerr?language=objc)
35pub const badPasteboardIndexErr: c_int = -25131;
36/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/badpasteboarditemerr?language=objc)
37pub const badPasteboardItemErr: c_int = -25132;
38/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/badpasteboardflavorerr?language=objc)
39pub const badPasteboardFlavorErr: c_int = -25133;
40/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/duplicatepasteboardflavorerr?language=objc)
41pub const duplicatePasteboardFlavorErr: c_int = -25134;
42/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/notpasteboardownererr?language=objc)
43pub const notPasteboardOwnerErr: c_int = -25135;
44/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/nopasteboardpromisekeepererr?language=objc)
45pub const noPasteboardPromiseKeeperErr: c_int = -25136;
46
47/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/pasteboardsyncflags?language=objc)
48// NS_OPTIONS
49#[repr(transparent)]
50#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
51pub struct PasteboardSyncFlags(pub OptionBits);
52bitflags::bitflags! {
53    impl PasteboardSyncFlags: OptionBits {
54        #[doc(alias = "kPasteboardModified")]
55        const Modified = 1<<0;
56        #[doc(alias = "kPasteboardClientIsOwner")]
57        const ClientIsOwner = 1<<1;
58    }
59}
60
61#[cfg(feature = "objc2")]
62unsafe impl Encode for PasteboardSyncFlags {
63    const ENCODING: Encoding = OptionBits::ENCODING;
64}
65
66#[cfg(feature = "objc2")]
67unsafe impl RefEncode for PasteboardSyncFlags {
68    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
69}
70
71/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/pasteboardflavorflags?language=objc)
72// NS_OPTIONS
73#[repr(transparent)]
74#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
75pub struct PasteboardFlavorFlags(pub OptionBits);
76bitflags::bitflags! {
77    impl PasteboardFlavorFlags: OptionBits {
78        #[doc(alias = "kPasteboardFlavorNoFlags")]
79        const NoFlags = 0;
80        #[doc(alias = "kPasteboardFlavorSenderOnly")]
81        const SenderOnly = 1<<0;
82        #[doc(alias = "kPasteboardFlavorSenderTranslated")]
83        const SenderTranslated = 1<<1;
84        #[doc(alias = "kPasteboardFlavorNotSaved")]
85        const NotSaved = 1<<2;
86        #[doc(alias = "kPasteboardFlavorRequestOnly")]
87        const RequestOnly = 1<<3;
88        #[doc(alias = "kPasteboardFlavorSystemTranslated")]
89        const SystemTranslated = 1<<8;
90        #[doc(alias = "kPasteboardFlavorPromised")]
91        const Promised = 1<<9;
92    }
93}
94
95#[cfg(feature = "objc2")]
96unsafe impl Encode for PasteboardFlavorFlags {
97    const ENCODING: Encoding = OptionBits::ENCODING;
98}
99
100#[cfg(feature = "objc2")]
101unsafe impl RefEncode for PasteboardFlavorFlags {
102    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
103}
104
105/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/pasteboardstandardlocation?language=objc)
106// NS_ENUM
107#[repr(transparent)]
108#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
109pub struct PasteboardStandardLocation(pub OSType);
110impl PasteboardStandardLocation {
111    #[doc(alias = "kPasteboardStandardLocationTrash")]
112    pub const Trash: Self = Self(0x74727368);
113    #[doc(alias = "kPasteboardStandardLocationUnknown")]
114    pub const Unknown: Self = Self(0x756e6b6e);
115}
116
117#[cfg(feature = "objc2")]
118unsafe impl Encode for PasteboardStandardLocation {
119    const ENCODING: Encoding = OSType::ENCODING;
120}
121
122#[cfg(feature = "objc2")]
123unsafe impl RefEncode for PasteboardStandardLocation {
124    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
125}
126
127unsafe impl ConcreteType for Pasteboard {
128    #[doc(alias = "PasteboardGetTypeID")]
129    #[inline]
130    fn type_id() -> CFTypeID {
131        extern "C-unwind" {
132            fn PasteboardGetTypeID() -> CFTypeID;
133        }
134        unsafe { PasteboardGetTypeID() }
135    }
136}
137
138impl Pasteboard {
139    /// # Safety
140    ///
141    /// `out_pasteboard` must be a valid pointer.
142    #[doc(alias = "PasteboardCreate")]
143    #[inline]
144    pub unsafe fn create(
145        in_name: Option<&CFString>,
146        out_pasteboard: NonNull<*mut Pasteboard>,
147    ) -> OSStatus {
148        extern "C-unwind" {
149            fn PasteboardCreate(
150                in_name: Option<&CFString>,
151                out_pasteboard: NonNull<*mut Pasteboard>,
152            ) -> OSStatus;
153        }
154        unsafe { PasteboardCreate(in_name, out_pasteboard) }
155    }
156
157    #[doc(alias = "PasteboardSynchronize")]
158    #[inline]
159    pub unsafe fn synchronize(&self) -> PasteboardSyncFlags {
160        extern "C-unwind" {
161            fn PasteboardSynchronize(in_pasteboard: &Pasteboard) -> PasteboardSyncFlags;
162        }
163        unsafe { PasteboardSynchronize(self) }
164    }
165
166    #[doc(alias = "PasteboardClear")]
167    #[inline]
168    pub unsafe fn clear(&self) -> OSStatus {
169        extern "C-unwind" {
170            fn PasteboardClear(in_pasteboard: &Pasteboard) -> OSStatus;
171        }
172        unsafe { PasteboardClear(self) }
173    }
174
175    /// # Safety
176    ///
177    /// `out_name` must be a valid pointer.
178    #[doc(alias = "PasteboardCopyName")]
179    #[inline]
180    pub unsafe fn copy_name(&self, out_name: NonNull<*const CFString>) -> OSStatus {
181        extern "C-unwind" {
182            fn PasteboardCopyName(
183                in_pasteboard: &Pasteboard,
184                out_name: NonNull<*const CFString>,
185            ) -> OSStatus;
186        }
187        unsafe { PasteboardCopyName(self, out_name) }
188    }
189
190    /// # Safety
191    ///
192    /// `out_item_count` must be a valid pointer.
193    #[doc(alias = "PasteboardGetItemCount")]
194    #[inline]
195    pub unsafe fn item_count(&self, out_item_count: NonNull<ItemCount>) -> OSStatus {
196        extern "C-unwind" {
197            fn PasteboardGetItemCount(
198                in_pasteboard: &Pasteboard,
199                out_item_count: NonNull<ItemCount>,
200            ) -> OSStatus;
201        }
202        unsafe { PasteboardGetItemCount(self, out_item_count) }
203    }
204
205    /// # Safety
206    ///
207    /// `out_item` must be a valid pointer.
208    #[doc(alias = "PasteboardGetItemIdentifier")]
209    #[inline]
210    pub unsafe fn item_identifier(
211        &self,
212        in_index: CFIndex,
213        out_item: NonNull<PasteboardItemID>,
214    ) -> OSStatus {
215        extern "C-unwind" {
216            fn PasteboardGetItemIdentifier(
217                in_pasteboard: &Pasteboard,
218                in_index: CFIndex,
219                out_item: NonNull<PasteboardItemID>,
220            ) -> OSStatus;
221        }
222        unsafe { PasteboardGetItemIdentifier(self, in_index, out_item) }
223    }
224
225    /// # Safety
226    ///
227    /// - `in_item` must be a valid pointer.
228    /// - `out_flavor_types` must be a valid pointer.
229    #[doc(alias = "PasteboardCopyItemFlavors")]
230    #[inline]
231    pub unsafe fn copy_item_flavors(
232        &self,
233        in_item: PasteboardItemID,
234        out_flavor_types: NonNull<*const CFArray>,
235    ) -> OSStatus {
236        extern "C-unwind" {
237            fn PasteboardCopyItemFlavors(
238                in_pasteboard: &Pasteboard,
239                in_item: PasteboardItemID,
240                out_flavor_types: NonNull<*const CFArray>,
241            ) -> OSStatus;
242        }
243        unsafe { PasteboardCopyItemFlavors(self, in_item, out_flavor_types) }
244    }
245
246    /// # Safety
247    ///
248    /// - `in_item` must be a valid pointer.
249    /// - `out_flags` must be a valid pointer.
250    #[doc(alias = "PasteboardGetItemFlavorFlags")]
251    #[inline]
252    pub unsafe fn item_flavor_flags(
253        &self,
254        in_item: PasteboardItemID,
255        in_flavor_type: &CFString,
256        out_flags: NonNull<PasteboardFlavorFlags>,
257    ) -> OSStatus {
258        extern "C-unwind" {
259            fn PasteboardGetItemFlavorFlags(
260                in_pasteboard: &Pasteboard,
261                in_item: PasteboardItemID,
262                in_flavor_type: &CFString,
263                out_flags: NonNull<PasteboardFlavorFlags>,
264            ) -> OSStatus;
265        }
266        unsafe { PasteboardGetItemFlavorFlags(self, in_item, in_flavor_type, out_flags) }
267    }
268
269    /// # Safety
270    ///
271    /// - `in_item` must be a valid pointer.
272    /// - `out_data` must be a valid pointer.
273    #[doc(alias = "PasteboardCopyItemFlavorData")]
274    #[inline]
275    pub unsafe fn copy_item_flavor_data(
276        &self,
277        in_item: PasteboardItemID,
278        in_flavor_type: &CFString,
279        out_data: NonNull<*const CFData>,
280    ) -> OSStatus {
281        extern "C-unwind" {
282            fn PasteboardCopyItemFlavorData(
283                in_pasteboard: &Pasteboard,
284                in_item: PasteboardItemID,
285                in_flavor_type: &CFString,
286                out_data: NonNull<*const CFData>,
287            ) -> OSStatus;
288        }
289        unsafe { PasteboardCopyItemFlavorData(self, in_item, in_flavor_type, out_data) }
290    }
291
292    /// # Safety
293    ///
294    /// `in_item` must be a valid pointer.
295    #[doc(alias = "PasteboardPutItemFlavor")]
296    #[inline]
297    pub unsafe fn put_item_flavor(
298        &self,
299        in_item: PasteboardItemID,
300        in_flavor_type: &CFString,
301        in_data: Option<&CFData>,
302        in_flags: PasteboardFlavorFlags,
303    ) -> OSStatus {
304        extern "C-unwind" {
305            fn PasteboardPutItemFlavor(
306                in_pasteboard: &Pasteboard,
307                in_item: PasteboardItemID,
308                in_flavor_type: &CFString,
309                in_data: Option<&CFData>,
310                in_flags: PasteboardFlavorFlags,
311            ) -> OSStatus;
312        }
313        unsafe { PasteboardPutItemFlavor(self, in_item, in_flavor_type, in_data, in_flags) }
314    }
315
316    /// # Safety
317    ///
318    /// `out_paste_location` must be a valid pointer.
319    #[doc(alias = "PasteboardCopyPasteLocation")]
320    #[inline]
321    pub unsafe fn copy_paste_location(
322        &self,
323        out_paste_location: NonNull<*const CFURL>,
324    ) -> OSStatus {
325        extern "C-unwind" {
326            fn PasteboardCopyPasteLocation(
327                in_pasteboard: &Pasteboard,
328                out_paste_location: NonNull<*const CFURL>,
329            ) -> OSStatus;
330        }
331        unsafe { PasteboardCopyPasteLocation(self, out_paste_location) }
332    }
333
334    #[doc(alias = "PasteboardSetPasteLocation")]
335    #[inline]
336    pub unsafe fn set_paste_location(&self, in_paste_location: &CFURL) -> OSStatus {
337        extern "C-unwind" {
338            fn PasteboardSetPasteLocation(
339                in_pasteboard: &Pasteboard,
340                in_paste_location: &CFURL,
341            ) -> OSStatus;
342        }
343        unsafe { PasteboardSetPasteLocation(self, in_paste_location) }
344    }
345}
346
347/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/pasteboardpromisekeeperprocptr?language=objc)
348pub type PasteboardPromiseKeeperProcPtr = Option<
349    unsafe extern "C-unwind" fn(
350        NonNull<Pasteboard>,
351        PasteboardItemID,
352        NonNull<CFString>,
353        *mut c_void,
354    ) -> OSStatus,
355>;
356
357impl Pasteboard {
358    /// # Safety
359    ///
360    /// - `in_promise_keeper` must be implemented correctly.
361    /// - `in_context` must be a valid pointer or null.
362    #[doc(alias = "PasteboardSetPromiseKeeper")]
363    #[inline]
364    pub unsafe fn set_promise_keeper(
365        &self,
366        in_promise_keeper: PasteboardPromiseKeeperProcPtr,
367        in_context: *mut c_void,
368    ) -> OSStatus {
369        extern "C-unwind" {
370            fn PasteboardSetPromiseKeeper(
371                in_pasteboard: &Pasteboard,
372                in_promise_keeper: PasteboardPromiseKeeperProcPtr,
373                in_context: *mut c_void,
374            ) -> OSStatus;
375        }
376        unsafe { PasteboardSetPromiseKeeper(self, in_promise_keeper, in_context) }
377    }
378
379    #[doc(alias = "PasteboardResolvePromises")]
380    #[inline]
381    pub unsafe fn resolve_promises(&self) -> OSStatus {
382        extern "C-unwind" {
383            fn PasteboardResolvePromises(in_pasteboard: &Pasteboard) -> OSStatus;
384        }
385        unsafe { PasteboardResolvePromises(self) }
386    }
387}
388
389extern "C-unwind" {
390    #[deprecated = "renamed to `Pasteboard::create`"]
391    pub fn PasteboardCreate(
392        in_name: Option<&CFString>,
393        out_pasteboard: NonNull<*mut Pasteboard>,
394    ) -> OSStatus;
395}
396
397extern "C-unwind" {
398    #[deprecated = "renamed to `Pasteboard::synchronize`"]
399    pub fn PasteboardSynchronize(in_pasteboard: &Pasteboard) -> PasteboardSyncFlags;
400}
401
402extern "C-unwind" {
403    #[deprecated = "renamed to `Pasteboard::clear`"]
404    pub fn PasteboardClear(in_pasteboard: &Pasteboard) -> OSStatus;
405}
406
407extern "C-unwind" {
408    #[deprecated = "renamed to `Pasteboard::copy_name`"]
409    pub fn PasteboardCopyName(
410        in_pasteboard: &Pasteboard,
411        out_name: NonNull<*const CFString>,
412    ) -> OSStatus;
413}
414
415extern "C-unwind" {
416    #[deprecated = "renamed to `Pasteboard::item_count`"]
417    pub fn PasteboardGetItemCount(
418        in_pasteboard: &Pasteboard,
419        out_item_count: NonNull<ItemCount>,
420    ) -> OSStatus;
421}
422
423extern "C-unwind" {
424    #[deprecated = "renamed to `Pasteboard::item_identifier`"]
425    pub fn PasteboardGetItemIdentifier(
426        in_pasteboard: &Pasteboard,
427        in_index: CFIndex,
428        out_item: NonNull<PasteboardItemID>,
429    ) -> OSStatus;
430}
431
432extern "C-unwind" {
433    #[deprecated = "renamed to `Pasteboard::copy_item_flavors`"]
434    pub fn PasteboardCopyItemFlavors(
435        in_pasteboard: &Pasteboard,
436        in_item: PasteboardItemID,
437        out_flavor_types: NonNull<*const CFArray>,
438    ) -> OSStatus;
439}
440
441extern "C-unwind" {
442    #[deprecated = "renamed to `Pasteboard::item_flavor_flags`"]
443    pub fn PasteboardGetItemFlavorFlags(
444        in_pasteboard: &Pasteboard,
445        in_item: PasteboardItemID,
446        in_flavor_type: &CFString,
447        out_flags: NonNull<PasteboardFlavorFlags>,
448    ) -> OSStatus;
449}
450
451extern "C-unwind" {
452    #[deprecated = "renamed to `Pasteboard::copy_item_flavor_data`"]
453    pub fn PasteboardCopyItemFlavorData(
454        in_pasteboard: &Pasteboard,
455        in_item: PasteboardItemID,
456        in_flavor_type: &CFString,
457        out_data: NonNull<*const CFData>,
458    ) -> OSStatus;
459}
460
461extern "C-unwind" {
462    #[deprecated = "renamed to `Pasteboard::put_item_flavor`"]
463    pub fn PasteboardPutItemFlavor(
464        in_pasteboard: &Pasteboard,
465        in_item: PasteboardItemID,
466        in_flavor_type: &CFString,
467        in_data: Option<&CFData>,
468        in_flags: PasteboardFlavorFlags,
469    ) -> OSStatus;
470}
471
472extern "C-unwind" {
473    #[deprecated = "renamed to `Pasteboard::copy_paste_location`"]
474    pub fn PasteboardCopyPasteLocation(
475        in_pasteboard: &Pasteboard,
476        out_paste_location: NonNull<*const CFURL>,
477    ) -> OSStatus;
478}
479
480extern "C-unwind" {
481    #[deprecated = "renamed to `Pasteboard::set_paste_location`"]
482    pub fn PasteboardSetPasteLocation(
483        in_pasteboard: &Pasteboard,
484        in_paste_location: &CFURL,
485    ) -> OSStatus;
486}
487
488extern "C-unwind" {
489    #[deprecated = "renamed to `Pasteboard::set_promise_keeper`"]
490    pub fn PasteboardSetPromiseKeeper(
491        in_pasteboard: &Pasteboard,
492        in_promise_keeper: PasteboardPromiseKeeperProcPtr,
493        in_context: *mut c_void,
494    ) -> OSStatus;
495}
496
497extern "C-unwind" {
498    #[deprecated = "renamed to `Pasteboard::resolve_promises`"]
499    pub fn PasteboardResolvePromises(in_pasteboard: &Pasteboard) -> OSStatus;
500}