objc2_quick_look_ui/generated/
QLPreviewReply.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::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8#[cfg(feature = "objc2-core-graphics")]
9use objc2_core_graphics::*;
10use objc2_foundation::*;
11#[cfg(feature = "objc2-uniform-type-identifiers")]
12use objc2_uniform_type_identifiers::*;
13
14use crate::*;
15
16extern_class!(
17    /// QLPreviewReplyAttachment is used to provide data for attachment in html data-based previews.
18    ///
19    /// See also [Apple's documentation](https://developer.apple.com/documentation/quicklookui/qlpreviewreplyattachment?language=objc)
20    #[unsafe(super(NSObject))]
21    #[derive(Debug, PartialEq, Eq, Hash)]
22    pub struct QLPreviewReplyAttachment;
23);
24
25extern_conformance!(
26    unsafe impl NSObjectProtocol for QLPreviewReplyAttachment {}
27);
28
29impl QLPreviewReplyAttachment {
30    extern_methods!(
31        /// The data content of an html preview
32        #[unsafe(method(data))]
33        #[unsafe(method_family = none)]
34        pub unsafe fn data(&self) -> Retained<NSData>;
35
36        #[cfg(feature = "objc2-uniform-type-identifiers")]
37        /// The content type of the attachment for an html preview
38        #[unsafe(method(contentType))]
39        #[unsafe(method_family = none)]
40        pub unsafe fn contentType(&self) -> Retained<UTType>;
41
42        #[cfg(feature = "objc2-uniform-type-identifiers")]
43        /// Create an attachment for html previews by providing the data and mime type of the attachment.
44        ///
45        /// Parameter `data`: The data content of an html preview
46        ///
47        /// Parameter `contentType`: The UTType of the attachment for an html preview
48        #[unsafe(method(initWithData:contentType:))]
49        #[unsafe(method_family = init)]
50        pub unsafe fn initWithData_contentType(
51            this: Allocated<Self>,
52            data: &NSData,
53            content_type: &UTType,
54        ) -> Retained<Self>;
55    );
56}
57
58/// Methods declared on superclass `NSObject`.
59impl QLPreviewReplyAttachment {
60    extern_methods!(
61        #[unsafe(method(init))]
62        #[unsafe(method_family = init)]
63        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
64
65        #[unsafe(method(new))]
66        #[unsafe(method_family = new)]
67        pub unsafe fn new() -> Retained<Self>;
68    );
69}
70
71extern_class!(
72    /// To provide a data-based preview, you have to return a QLPreviewReply object.
73    ///
74    /// See also [Apple's documentation](https://developer.apple.com/documentation/quicklookui/qlpreviewreply?language=objc)
75    #[unsafe(super(NSObject))]
76    #[derive(Debug, PartialEq, Eq, Hash)]
77    pub struct QLPreviewReply;
78);
79
80extern_conformance!(
81    unsafe impl NSObjectProtocol for QLPreviewReply {}
82);
83
84impl QLPreviewReply {
85    extern_methods!(
86        /// String encoding for text or html based previews. Defaults to NSUTF8StringEncoding.
87        #[unsafe(method(stringEncoding))]
88        #[unsafe(method_family = none)]
89        pub unsafe fn stringEncoding(&self) -> NSStringEncoding;
90
91        /// Setter for [`stringEncoding`][Self::stringEncoding].
92        #[unsafe(method(setStringEncoding:))]
93        #[unsafe(method_family = none)]
94        pub unsafe fn setStringEncoding(&self, string_encoding: NSStringEncoding);
95
96        /// Attachments for HTML data previews. The keys of the dictionary are the attachment identifiers (eg foo) that can be referenced with the cid:id URL (eg cid:foo).
97        #[unsafe(method(attachments))]
98        #[unsafe(method_family = none)]
99        pub unsafe fn attachments(
100            &self,
101        ) -> Retained<NSDictionary<NSString, QLPreviewReplyAttachment>>;
102
103        /// Setter for [`attachments`][Self::attachments].
104        #[unsafe(method(setAttachments:))]
105        #[unsafe(method_family = none)]
106        pub unsafe fn setAttachments(
107            &self,
108            attachments: &NSDictionary<NSString, QLPreviewReplyAttachment>,
109        );
110
111        /// Custom display title for the preview. If left as the empty string, QuickLook will use the file name.
112        #[unsafe(method(title))]
113        #[unsafe(method_family = none)]
114        pub unsafe fn title(&self) -> Retained<NSString>;
115
116        /// Setter for [`title`][Self::title].
117        #[unsafe(method(setTitle:))]
118        #[unsafe(method_family = none)]
119        pub unsafe fn setTitle(&self, title: &NSString);
120
121        #[cfg(all(
122            feature = "block2",
123            feature = "objc2-core-foundation",
124            feature = "objc2-core-graphics"
125        ))]
126        /// Use this method to provide a preview by drawing into a context.
127        ///
128        ///
129        /// Parameter `contextSize`: The size of your image.
130        ///
131        /// Parameter `isBitmap`: Whether the context should be bitmap or vector.
132        ///
133        /// Parameter `drawingBlock`: The preview should be drawn into the context passed to this block. The QLPreviewReply passed into this block is the same as the one created by this method and is provided for convenience for any further updates to its properties during the drawing block. Return YES if the preview was successfully drawn into the context. Return NO and populate error otherwise.
134        #[unsafe(method(initWithContextSize:isBitmap:drawingBlock:))]
135        #[unsafe(method_family = init)]
136        pub unsafe fn initWithContextSize_isBitmap_drawingBlock(
137            this: Allocated<Self>,
138            context_size: CGSize,
139            is_bitmap: bool,
140            drawing_block: &block2::DynBlock<
141                dyn Fn(NonNull<CGContext>, NonNull<QLPreviewReply>, *mut *mut NSError) -> Bool,
142            >,
143        ) -> Retained<Self>;
144
145        /// Use this method to provide a preview by providing a URL to a file of a supported type.
146        ///
147        ///
148        /// Parameter `fileURL`: A file URL representing a preview of the previewed URL. Currently supported types include: UTTypeImage, UTTypePDF, UTTypeHTML, UTTypeXML, UTTypePlainText, UTTypeRTF, UTTypeRTFD, UTTypeMovie, UTTypeAudio
149        #[unsafe(method(initWithFileURL:))]
150        #[unsafe(method_family = init)]
151        pub unsafe fn initWithFileURL(this: Allocated<Self>, file_url: &NSURL) -> Retained<Self>;
152
153        #[cfg(all(
154            feature = "block2",
155            feature = "objc2-core-foundation",
156            feature = "objc2-uniform-type-identifiers"
157        ))]
158        /// Use this method to provide a preview with data of a supported format.
159        ///
160        ///
161        /// Parameter `contentType`: The content type of the data.
162        ///
163        /// Parameter `contentSize`: A hint for the size you would like to display your content at. If your content has an intrinsic size built in, such as images and PDFs, that will be used as the final size, but providing the correct size here will allow QuickLook to present loading UI at the correct size before you are finished creating the data. QuickLook will use a default size if NSZeroSize is passed in.
164        ///
165        /// Parameter `dataCreationBlock`: Create and return data representing the file preview. Supported types include: UTTypeImage, UTTypePDF, UTTypeHTML, UTTypeXML, UTTypePlainText, UTTypeRTF. Heavy lifting should be done inside of the dataCreationBlock instead of when creating the QLPreviewReply. The QLPreviewReply passed into this block is the same as the one created by this method and is provided for convenience for any further updates to its properties, such as attachments, during the data generation. Return the data if successful. Populate error if unsuccessful.
166        #[unsafe(method(initWithDataOfContentType:contentSize:dataCreationBlock:))]
167        #[unsafe(method_family = init)]
168        pub unsafe fn initWithDataOfContentType_contentSize_dataCreationBlock(
169            this: Allocated<Self>,
170            content_type: &UTType,
171            content_size: CGSize,
172            data_creation_block: &block2::DynBlock<
173                dyn Fn(NonNull<QLPreviewReply>, *mut *mut NSError) -> *mut NSData,
174            >,
175        ) -> Retained<Self>;
176    );
177}
178
179/// Methods declared on superclass `NSObject`.
180impl QLPreviewReply {
181    extern_methods!(
182        #[unsafe(method(init))]
183        #[unsafe(method_family = init)]
184        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
185
186        #[unsafe(method(new))]
187        #[unsafe(method_family = new)]
188        pub unsafe fn new() -> Retained<Self>;
189    );
190}
191
192/// UI.
193impl QLPreviewReply {
194    extern_methods!();
195}