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::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
use objc2_foundation::*;
#[cfg(feature = "objc2-uniform-type-identifiers")]
use objc2_uniform_type_identifiers::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/quicklookthumbnailing/qlthumbnailgenerationrequestrepresentationtypes?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct QLThumbnailGenerationRequestRepresentationTypes(pub NSUInteger);
bitflags::bitflags! {
    impl QLThumbnailGenerationRequestRepresentationTypes: NSUInteger {
        #[doc(alias = "QLThumbnailGenerationRequestRepresentationTypeIcon")]
        const Icon = 1<<0;
        #[doc(alias = "QLThumbnailGenerationRequestRepresentationTypeLowQualityThumbnail")]
        const LowQualityThumbnail = 1<<1;
        #[doc(alias = "QLThumbnailGenerationRequestRepresentationTypeThumbnail")]
        const Thumbnail = 1<<2;
        #[doc(alias = "QLThumbnailGenerationRequestRepresentationTypeAll")]
        const All = NSUIntegerMax as _;
    }
}

unsafe impl Encode for QLThumbnailGenerationRequestRepresentationTypes {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for QLThumbnailGenerationRequestRepresentationTypes {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

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

extern_conformance!(
    unsafe impl NSCoding for QLThumbnailGenerationRequest {}
);

extern_conformance!(
    unsafe impl NSCopying for QLThumbnailGenerationRequest {}
);

unsafe impl CopyingHelper for QLThumbnailGenerationRequest {
    type Result = Self;
}

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

extern_conformance!(
    unsafe impl NSSecureCoding for QLThumbnailGenerationRequest {}
);

impl QLThumbnailGenerationRequest {
    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>;

        #[cfg(feature = "objc2-core-foundation")]
        /// Parameter `url`: The url of the file on disk for which a thumbnail is requested.
        ///
        /// Parameter `size`: The desired size of the thumbnails that should be generated.
        ///
        /// Parameter `scale`: The desired scale of the thumbnails that should be generated. This will usually be the scale of the screen.
        /// You can for instance pass a scale different from the one of the screen if you would like to save generated thumbnails to a server to later download them on devices with a different screen scale.
        ///
        /// Parameter `representationTypes`: The desired successive representations of the thumbnail that should be generated when possible.
        #[unsafe(method(initWithFileAtURL:size:scale:representationTypes:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithFileAtURL_size_scale_representationTypes(
            this: Allocated<Self>,
            url: &NSURL,
            size: CGSize,
            scale: CGFloat,
            representation_types: QLThumbnailGenerationRequestRepresentationTypes,
        ) -> Retained<Self>;

        #[cfg(feature = "objc2-uniform-type-identifiers")]
        /// The content type of the file being thumbnailed is used to determine the provider of the thumbnail and the icon styles applied if iconMode is requested. By default the content type is derived from the file extension. Setting this property will override the derived content type. This is useful for files that don't have meaningful extensions but for which you may already know the content type.
        #[unsafe(method(contentType))]
        #[unsafe(method_family = none)]
        pub unsafe fn contentType(&self) -> Retained<UTType>;

        #[cfg(feature = "objc2-uniform-type-identifiers")]
        /// Setter for [`contentType`][Self::contentType].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setContentType:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setContentType(&self, content_type: Option<&UTType>);

        #[cfg(feature = "objc2-core-foundation")]
        /// Defaults to 0. If set, the thumbnail will have a width and height greater or equal to minimumDimension * scale.
        /// If set and it is not possible to generate thumbnails of minimumDimension for any of the requested QLThumbnailGenerationRequestRepresentationTypes, no thumbnail will be provided.
        #[unsafe(method(minimumDimension))]
        #[unsafe(method_family = none)]
        pub unsafe fn minimumDimension(&self) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`minimumDimension`][Self::minimumDimension].
        #[unsafe(method(setMinimumDimension:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setMinimumDimension(&self, minimum_dimension: CGFloat);

        /// If set to YES, this will generate something appropriate for display as a file icon,
        /// meaning that the thumbnail might be embedded in a frame, show a curled corner, draw a background
        /// and/or a drop shadow, as appropriate for the platform.
        /// If set to NO, this will generate a raw undecorated thumbnail.
        /// Defaults to NO.
        #[unsafe(method(iconMode))]
        #[unsafe(method_family = none)]
        pub unsafe fn iconMode(&self) -> bool;

        /// Setter for [`iconMode`][Self::iconMode].
        #[unsafe(method(setIconMode:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setIconMode(&self, icon_mode: bool);

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(size))]
        #[unsafe(method_family = none)]
        pub unsafe fn size(&self) -> CGSize;

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(scale))]
        #[unsafe(method_family = none)]
        pub unsafe fn scale(&self) -> CGFloat;

        #[unsafe(method(representationTypes))]
        #[unsafe(method_family = none)]
        pub unsafe fn representationTypes(&self)
            -> QLThumbnailGenerationRequestRepresentationTypes;
    );
}