objc2-quick-look-ui 0.3.2

Bindings to the QuickLookUI framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

/// A type that defines a block used to load a Quick Look preview item.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/quicklookui/qlpreviewitemloadingblock?language=objc)
#[deprecated = "Use void (^)(NSError * _Nullable) instead"]
#[cfg(feature = "block2")]
pub type QLPreviewItemLoadingBlock = *mut block2::DynBlock<dyn Fn(*mut NSError)>;

extern_protocol!(
    /// A protocol for implementing a custom controller to create previews of files.
    ///
    /// A controller that implements the
    /// <doc
    /// ://com.apple.documentation/documentation/quicklook/qlpreviewingcontroller> protocol must at least implement
    /// <doc
    /// ://com.apple.documentation/documentation//quicklook/qlpreviewingcontroller/2882042-preparepreviewofsearchableitem> or
    /// <doc
    /// ://com.apple.documentation/documentation/quicklook/qlpreviewingcontroller/2867936-preparepreviewoffile>.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/quicklookui/qlpreviewingcontroller?language=objc)
    pub unsafe trait QLPreviewingController: NSObjectProtocol {
        #[cfg(feature = "block2")]
        /// Prepares the preview for a file by using the data from Spotlight’s searchable item.
        ///
        /// 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.
        /// - Parameters:
        /// - identifier: The identifier of the searchable item.
        /// - queryString: A search string to associate with the searchable item.
        /// - 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.
        #[optional]
        #[unsafe(method(preparePreviewOfSearchableItemWithIdentifier:queryString:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn preparePreviewOfSearchableItemWithIdentifier_queryString_completionHandler(
            &self,
            identifier: &NSString,
            query_string: Option<&NSString>,
            handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Prepares the preview of a file at the specified file’s URL.
        ///
        /// 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.
        ///
        /// When preparing and displaying the view controller, avoid holding open a file descriptors while the user is previewing the file.
        ///
        /// - Parameters:
        /// - url: The URL of the file to preview.
        /// - 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.
        #[optional]
        #[unsafe(method(preparePreviewOfFileAtURL:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn preparePreviewOfFileAtURL_completionHandler(
            &self,
            url: &NSURL,
            handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );

        #[cfg(all(
            feature = "QLFilePreviewRequest",
            feature = "QLPreviewReply",
            feature = "block2"
        ))]
        /// Prepares the preview of a file identified within a file preview request.
        ///
        /// - Parameters:
        /// - request: The file preview request that identifies the content to preview.
        /// - handler: The closure to call with a
        /// <doc
        /// ://com.apple.documentation/documentation/quicklook/qlpreviewreply> for the system to display as the preview.
        #[optional]
        #[unsafe(method(providePreviewForFileRequest:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn providePreviewForFileRequest_completionHandler(
            &self,
            request: &QLFilePreviewRequest,
            handler: &block2::DynBlock<dyn Fn(*mut QLPreviewReply, *mut NSError)>,
        );
    }
);