objc2_quick_look/generated/
QLThumbnail.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 = "dispatch2")]
8use dispatch2::*;
9#[cfg(feature = "objc2")]
10use objc2::__framework_prelude::*;
11use objc2_core_foundation::*;
12#[cfg(feature = "objc2-core-graphics")]
13use objc2_core_graphics::*;
14
15use crate::*;
16
17/// [Apple's documentation](https://developer.apple.com/documentation/quicklook/qlthumbnail?language=objc)
18#[doc(alias = "QLThumbnailRef")]
19#[repr(C)]
20pub struct QLThumbnail {
21    inner: [u8; 0],
22    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
23}
24
25cf_type!(
26    unsafe impl QLThumbnail {}
27);
28#[cfg(feature = "objc2")]
29cf_objc2_type!(
30    unsafe impl RefEncode<"__QLThumbnail"> for QLThumbnail {}
31);
32
33unsafe impl ConcreteType for QLThumbnail {
34    #[doc(alias = "QLThumbnailGetTypeID")]
35    #[inline]
36    fn type_id() -> CFTypeID {
37        extern "C-unwind" {
38            fn QLThumbnailGetTypeID() -> CFTypeID;
39        }
40        unsafe { QLThumbnailGetTypeID() }
41    }
42}
43
44impl QLThumbnail {
45    /// # Safety
46    ///
47    /// - `allocator` might not allow `None`.
48    /// - `url` might not allow `None`.
49    /// - `options` generics must be of the correct type.
50    /// - `options` might not allow `None`.
51    #[doc(alias = "QLThumbnailCreate")]
52    #[deprecated = "Use QLThumbnailGenerationRequest in QuickLookThumbnailing to generate thumbnails."]
53    #[inline]
54    pub unsafe fn new(
55        allocator: Option<&CFAllocator>,
56        url: Option<&CFURL>,
57        max_thumbnail_size: CGSize,
58        options: Option<&CFDictionary>,
59    ) -> Option<CFRetained<QLThumbnail>> {
60        extern "C-unwind" {
61            fn QLThumbnailCreate(
62                allocator: Option<&CFAllocator>,
63                url: Option<&CFURL>,
64                max_thumbnail_size: CGSize,
65                options: Option<&CFDictionary>,
66            ) -> Option<NonNull<QLThumbnail>>;
67        }
68        let ret = unsafe { QLThumbnailCreate(allocator, url, max_thumbnail_size, options) };
69        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
70    }
71
72    #[doc(alias = "QLThumbnailCopyDocumentURL")]
73    #[deprecated = "Use QuickLookThumbnailing for thumbnails."]
74    #[inline]
75    pub unsafe fn document_url(&self) -> Option<CFRetained<CFURL>> {
76        extern "C-unwind" {
77            fn QLThumbnailCopyDocumentURL(thumbnail: &QLThumbnail) -> Option<NonNull<CFURL>>;
78        }
79        let ret = unsafe { QLThumbnailCopyDocumentURL(self) };
80        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
81    }
82
83    #[doc(alias = "QLThumbnailGetMaximumSize")]
84    #[deprecated = "Use QLThumbnailGenerationRequest in QuickLookThumbnailing."]
85    #[inline]
86    pub unsafe fn maximum_size(&self) -> CGSize {
87        extern "C-unwind" {
88            fn QLThumbnailGetMaximumSize(thumbnail: &QLThumbnail) -> CGSize;
89        }
90        unsafe { QLThumbnailGetMaximumSize(self) }
91    }
92
93    #[doc(alias = "QLThumbnailCopyOptions")]
94    #[deprecated = "Use QuickLookThumbnailing for thumbnails."]
95    #[inline]
96    pub unsafe fn options(&self) -> Option<CFRetained<CFDictionary>> {
97        extern "C-unwind" {
98            fn QLThumbnailCopyOptions(thumbnail: &QLThumbnail) -> Option<NonNull<CFDictionary>>;
99        }
100        let ret = unsafe { QLThumbnailCopyOptions(self) };
101        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
102    }
103
104    /// # Safety
105    ///
106    /// - `queue` possibly has additional threading requirements.
107    /// - `queue` might not allow `None`.
108    /// - `completion` must be a valid pointer.
109    #[doc(alias = "QLThumbnailDispatchAsync")]
110    #[cfg(feature = "dispatch2")]
111    #[deprecated = "Use QLThumbnailGenerator in QuickLookThumbnailing to generate thumbnails."]
112    #[inline]
113    pub unsafe fn dispatch_async(
114        &self,
115        queue: Option<&DispatchQueue>,
116        completion: dispatch_block_t,
117    ) {
118        extern "C-unwind" {
119            fn QLThumbnailDispatchAsync(
120                thumbnail: &QLThumbnail,
121                queue: Option<&DispatchQueue>,
122                completion: dispatch_block_t,
123            );
124        }
125        unsafe { QLThumbnailDispatchAsync(self, queue, completion) }
126    }
127
128    #[doc(alias = "QLThumbnailCopyImage")]
129    #[cfg(feature = "objc2-core-graphics")]
130    #[deprecated = "Use QuickLookThumbnailing for thumbnails."]
131    #[inline]
132    pub unsafe fn image(&self) -> Option<CFRetained<CGImage>> {
133        extern "C-unwind" {
134            fn QLThumbnailCopyImage(thumbnail: &QLThumbnail) -> Option<NonNull<CGImage>>;
135        }
136        let ret = unsafe { QLThumbnailCopyImage(self) };
137        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
138    }
139
140    #[doc(alias = "QLThumbnailGetContentRect")]
141    #[deprecated = "Use QuickLookThumbnailing for thumbnails."]
142    #[inline]
143    pub unsafe fn content_rect(&self) -> CGRect {
144        extern "C-unwind" {
145            fn QLThumbnailGetContentRect(thumbnail: &QLThumbnail) -> CGRect;
146        }
147        unsafe { QLThumbnailGetContentRect(self) }
148    }
149
150    #[doc(alias = "QLThumbnailCancel")]
151    #[deprecated = "Use [QLThumbnailGenerator cancelRequest:] in QuickLookThumbnailing."]
152    #[inline]
153    pub unsafe fn cancel(&self) {
154        extern "C-unwind" {
155            fn QLThumbnailCancel(thumbnail: &QLThumbnail);
156        }
157        unsafe { QLThumbnailCancel(self) }
158    }
159
160    #[doc(alias = "QLThumbnailIsCancelled")]
161    #[deprecated = "Use QuickLookThumbnailing for thumbnails."]
162    #[inline]
163    pub unsafe fn is_cancelled(&self) -> bool {
164        extern "C-unwind" {
165            fn QLThumbnailIsCancelled(thumbnail: &QLThumbnail) -> Boolean;
166        }
167        let ret = unsafe { QLThumbnailIsCancelled(self) };
168        ret != 0
169    }
170}
171
172#[deprecated = "renamed to `QLThumbnail::new`"]
173#[inline]
174pub unsafe extern "C-unwind" fn QLThumbnailCreate(
175    allocator: Option<&CFAllocator>,
176    url: Option<&CFURL>,
177    max_thumbnail_size: CGSize,
178    options: Option<&CFDictionary>,
179) -> Option<CFRetained<QLThumbnail>> {
180    extern "C-unwind" {
181        fn QLThumbnailCreate(
182            allocator: Option<&CFAllocator>,
183            url: Option<&CFURL>,
184            max_thumbnail_size: CGSize,
185            options: Option<&CFDictionary>,
186        ) -> Option<NonNull<QLThumbnail>>;
187    }
188    let ret = unsafe { QLThumbnailCreate(allocator, url, max_thumbnail_size, options) };
189    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
190}
191
192#[deprecated = "renamed to `QLThumbnail::document_url`"]
193#[inline]
194pub unsafe extern "C-unwind" fn QLThumbnailCopyDocumentURL(
195    thumbnail: &QLThumbnail,
196) -> Option<CFRetained<CFURL>> {
197    extern "C-unwind" {
198        fn QLThumbnailCopyDocumentURL(thumbnail: &QLThumbnail) -> Option<NonNull<CFURL>>;
199    }
200    let ret = unsafe { QLThumbnailCopyDocumentURL(thumbnail) };
201    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
202}
203
204extern "C-unwind" {
205    #[deprecated = "renamed to `QLThumbnail::maximum_size`"]
206    pub fn QLThumbnailGetMaximumSize(thumbnail: &QLThumbnail) -> CGSize;
207}
208
209#[deprecated = "renamed to `QLThumbnail::options`"]
210#[inline]
211pub unsafe extern "C-unwind" fn QLThumbnailCopyOptions(
212    thumbnail: &QLThumbnail,
213) -> Option<CFRetained<CFDictionary>> {
214    extern "C-unwind" {
215        fn QLThumbnailCopyOptions(thumbnail: &QLThumbnail) -> Option<NonNull<CFDictionary>>;
216    }
217    let ret = unsafe { QLThumbnailCopyOptions(thumbnail) };
218    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
219}
220
221extern "C-unwind" {
222    #[cfg(feature = "dispatch2")]
223    #[deprecated = "renamed to `QLThumbnail::dispatch_async`"]
224    pub fn QLThumbnailDispatchAsync(
225        thumbnail: &QLThumbnail,
226        queue: Option<&DispatchQueue>,
227        completion: dispatch_block_t,
228    );
229}
230
231#[cfg(feature = "objc2-core-graphics")]
232#[deprecated = "renamed to `QLThumbnail::image`"]
233#[inline]
234pub unsafe extern "C-unwind" fn QLThumbnailCopyImage(
235    thumbnail: &QLThumbnail,
236) -> Option<CFRetained<CGImage>> {
237    extern "C-unwind" {
238        fn QLThumbnailCopyImage(thumbnail: &QLThumbnail) -> Option<NonNull<CGImage>>;
239    }
240    let ret = unsafe { QLThumbnailCopyImage(thumbnail) };
241    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
242}
243
244extern "C-unwind" {
245    #[deprecated = "renamed to `QLThumbnail::content_rect`"]
246    pub fn QLThumbnailGetContentRect(thumbnail: &QLThumbnail) -> CGRect;
247}
248
249extern "C-unwind" {
250    #[deprecated = "renamed to `QLThumbnail::cancel`"]
251    pub fn QLThumbnailCancel(thumbnail: &QLThumbnail);
252}
253
254#[deprecated = "renamed to `QLThumbnail::is_cancelled`"]
255#[inline]
256pub unsafe extern "C-unwind" fn QLThumbnailIsCancelled(thumbnail: &QLThumbnail) -> bool {
257    extern "C-unwind" {
258        fn QLThumbnailIsCancelled(thumbnail: &QLThumbnail) -> Boolean;
259    }
260    let ret = unsafe { QLThumbnailIsCancelled(thumbnail) };
261    ret != 0
262}