objc2-quick-look-thumbnailing 0.3.2

Bindings to the QuickLookThumbnailing 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::*;
#[cfg(feature = "objc2-uniform-type-identifiers")]
use objc2_uniform_type_identifiers::*;

use crate::*;

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/quicklookthumbnailing/qlthumbnailgenerator?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct QLThumbnailGenerator;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for QLThumbnailGenerator {}
);

impl QLThumbnailGenerator {
    extern_methods!(
        #[unsafe(method(sharedGenerator))]
        #[unsafe(method_family = none)]
        pub unsafe fn sharedGenerator() -> Retained<QLThumbnailGenerator>;

        #[cfg(all(
            feature = "QLThumbnailGenerationRequest",
            feature = "QLThumbnailRepresentation",
            feature = "block2"
        ))]
        /// Parameter `completionHandler`: Always called when the thumbnail generation is over.
        /// The thumbnail passed to this handler is the most representative version of the thumbnail that was successfully generated (if any).
        /// If set, the error contains information about the issue that occurred while trying to generate the thumbnail.
        /// QLThumbnail error codes can be found in
        /// <QuickLookThumbnailing
        /// /QLThumbnailErrors.h>.
        #[unsafe(method(generateBestRepresentationForRequest:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn generateBestRepresentationForRequest_completionHandler(
            &self,
            request: &QLThumbnailGenerationRequest,
            completion_handler: &block2::DynBlock<
                dyn Fn(*mut QLThumbnailRepresentation, *mut NSError),
            >,
        );

        #[cfg(all(
            feature = "QLThumbnailGenerationRequest",
            feature = "QLThumbnailRepresentation",
            feature = "block2"
        ))]
        /// Parameter `updateHandler`: Called for the successive requested representations of a thumbnail.
        /// If a representation was not successfully generated, this may be called with a nil representation.
        /// If a requested more representative version was successfully generated before a less representative one, this handler will be called only for the more representative version, skipping the less representative one.
        /// This handler is guaranteed to be called at least once, for the requested most representative version, whether a representation could be successfully generated or not.
        /// If set, the error contains information about the issue that occurred while trying to generate the representation of the given type.
        /// QLThumbnail error codes can be found in
        /// <QuickLookThumbnailing
        /// /QLThumbnailErrors.h>.
        #[unsafe(method(generateRepresentationsForRequest:updateHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn generateRepresentationsForRequest_updateHandler(
            &self,
            request: &QLThumbnailGenerationRequest,
            update_handler: Option<
                &block2::DynBlock<
                    dyn Fn(
                        *mut QLThumbnailRepresentation,
                        QLThumbnailRepresentationType,
                        *mut NSError,
                    ),
                >,
            >,
        );

        #[cfg(feature = "QLThumbnailGenerationRequest")]
        /// Cancels the given QLThumbnailGenerationRequest.
        ///
        /// Parameter `request`: The request that should be cancelled.
        #[unsafe(method(cancelRequest:))]
        #[unsafe(method_family = none)]
        pub unsafe fn cancelRequest(&self, request: &QLThumbnailGenerationRequest);

        #[cfg(all(
            feature = "QLThumbnailGenerationRequest",
            feature = "block2",
            feature = "objc2-uniform-type-identifiers"
        ))]
        /// Saves a thumbnail for the request on disk at fileURL.
        /// The file saved at fileURL has to be deleted when it is not used anymore.
        /// This is primarily intended for file provider extensions which need to upload thumbnails and have a small memory limit.
        ///
        ///
        /// Parameter `contentType`: An image content type to save the thumbnail as, supported by CGImageDestination, such as UTTypePNG or UTTypeJPEG
        ///
        /// Parameter `completionHandler`: Always called when the thumbnail generation is over. Will contain an error if the thumbnail could not be successfully saved to disk at fileURL.
        #[unsafe(method(saveBestRepresentationForRequest:toFileAtURL:asContentType:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn saveBestRepresentationForRequest_toFileAtURL_asContentType_completionHandler(
            &self,
            request: &QLThumbnailGenerationRequest,
            file_url: &NSURL,
            content_type: &UTType,
            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );

        #[cfg(all(feature = "QLThumbnailGenerationRequest", feature = "block2"))]
        /// Saves a thumbnail for the request on disk at fileURL.
        /// The file saved at fileURL has to be deleted when it is not used anymore.
        /// This is primarily intended for file provider extensions which need to upload thumbnails and have a small memory limit.
        ///
        ///
        /// Parameter `contentType`: An image content type to save the thumbnail as, supported by CGImageDestination, such as kUTTypePNG or kUTTypeJPEG
        ///
        /// Parameter `completionHandler`: Always called when the thumbnail generation is over. Will contain an error if the thumbnail could not be successfully saved to disk at fileURL.
        #[deprecated]
        #[unsafe(method(saveBestRepresentationForRequest:toFileAtURL:withContentType:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn saveBestRepresentationForRequest_toFileAtURL_withContentType_completionHandler(
            &self,
            request: &QLThumbnailGenerationRequest,
            file_url: &NSURL,
            content_type: &NSString,
            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );
    );
}

/// Methods declared on superclass `NSObject`.
impl QLThumbnailGenerator {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}