objc2_quick_look_ui/generated/QLPreviewingController.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
10/// A type that defines a block used to load a Quick Look preview item.
11///
12/// See also [Apple's documentation](https://developer.apple.com/documentation/quicklookui/qlpreviewitemloadingblock?language=objc)
13#[cfg(feature = "block2")]
14pub type QLPreviewItemLoadingBlock = *mut block2::DynBlock<dyn Fn(*mut NSError)>;
15
16extern_protocol!(
17 /// A protocol for implementing a custom controller to create previews of files.
18 ///
19 /// A controller that implements the
20 /// <doc
21 /// ://com.apple.documentation/documentation/quicklook/qlpreviewingcontroller> protocol must at least implement
22 /// <doc
23 /// ://com.apple.documentation/documentation//quicklook/qlpreviewingcontroller/2882042-preparepreviewofsearchableitem> or
24 /// <doc
25 /// ://com.apple.documentation/documentation/quicklook/qlpreviewingcontroller/2867936-preparepreviewoffile>.
26 ///
27 /// See also [Apple's documentation](https://developer.apple.com/documentation/quicklookui/qlpreviewingcontroller?language=objc)
28 pub unsafe trait QLPreviewingController: NSObjectProtocol {
29 #[cfg(feature = "block2")]
30 /// Prepares the preview for a file by using the data from Spotlight’s searchable item.
31 ///
32 /// The operating system calls this method only once from the main thread before it presents the previewing controller. To avoid blocking the main thread, don’t perform long-running or resource-intensive work.
33 /// - Parameters:
34 /// - identifier: The identifier of the searchable item.
35 /// - queryString: A search string to associate with the searchable item.
36 /// - handler: A completion handler that notifies the platform that a preview is available. The operating system shows a loading spinner, so call the handler as soon as possible. You can call the completion handler asynchronously after returning from the callback.
37 #[optional]
38 #[unsafe(method(preparePreviewOfSearchableItemWithIdentifier:queryString:completionHandler:))]
39 #[unsafe(method_family = none)]
40 unsafe fn preparePreviewOfSearchableItemWithIdentifier_queryString_completionHandler(
41 &self,
42 identifier: &NSString,
43 query_string: Option<&NSString>,
44 handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
45 );
46
47 #[cfg(feature = "block2")]
48 /// Prepares the preview of a file at the specified file’s URL.
49 ///
50 /// The operating system calls this method only once from the main thread before it presents the previewing controller. To avoid blocking the main thread, don’t perform long-running or resource-intensive work.
51 ///
52 /// When preparing and displaying the view controller, avoid holding open a file descriptors while the user is previewing the file.
53 ///
54 /// - Parameters:
55 /// - url: The URL of the file to preview.
56 /// - handler: A completion handler that notifies the platform that a preview is available. The operating system shows a loading spinner, so call the handler as soon as possible. You can call the completion handler asynchronously after returning from the callback.
57 #[optional]
58 #[unsafe(method(preparePreviewOfFileAtURL:completionHandler:))]
59 #[unsafe(method_family = none)]
60 unsafe fn preparePreviewOfFileAtURL_completionHandler(
61 &self,
62 url: &NSURL,
63 handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
64 );
65
66 #[cfg(all(
67 feature = "QLFilePreviewRequest",
68 feature = "QLPreviewReply",
69 feature = "block2"
70 ))]
71 /// Prepares the preview of a file identified within a file preview request.
72 ///
73 /// - Parameters:
74 /// - request: The file preview request that identifies the content to preview.
75 /// - handler: The closure to call with a
76 /// <doc
77 /// ://com.apple.documentation/documentation/quicklook/qlpreviewreply> for the system to display as the preview.
78 #[optional]
79 #[unsafe(method(providePreviewForFileRequest:completionHandler:))]
80 #[unsafe(method_family = none)]
81 unsafe fn providePreviewForFileRequest_completionHandler(
82 &self,
83 request: &QLFilePreviewRequest,
84 handler: &block2::DynBlock<dyn Fn(*mut QLPreviewReply, *mut NSError)>,
85 );
86 }
87);