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::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
use objc2_app_kit::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
#[cfg(feature = "objc2-core-graphics")]
use objc2_core_graphics::*;
#[cfg(feature = "objc2-ui-kit")]
#[cfg(any(target_os = "ios", target_os = "visionos"))]
use objc2_ui_kit::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/quicklookthumbnailing/qlthumbnailrepresentationtype?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct QLThumbnailRepresentationType(pub NSInteger);
impl QLThumbnailRepresentationType {
    #[doc(alias = "QLThumbnailRepresentationTypeIcon")]
    pub const Icon: Self = Self(0);
    #[doc(alias = "QLThumbnailRepresentationTypeLowQualityThumbnail")]
    pub const LowQualityThumbnail: Self = Self(1);
    #[doc(alias = "QLThumbnailRepresentationTypeThumbnail")]
    pub const Thumbnail: Self = Self(2);
}

unsafe impl Encode for QLThumbnailRepresentationType {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

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

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

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

impl QLThumbnailRepresentation {
    extern_methods!(
        #[unsafe(method(type))]
        #[unsafe(method_family = none)]
        pub unsafe fn r#type(&self) -> QLThumbnailRepresentationType;

        #[cfg(feature = "objc2-core-graphics")]
        /// Returns the CGImage representation of the thumbnail.
        #[unsafe(method(CGImage))]
        #[unsafe(method_family = none)]
        pub unsafe fn CGImage(&self) -> Retained<CGImage>;

        #[cfg(feature = "objc2-ui-kit")]
        #[cfg(any(target_os = "ios", target_os = "visionos"))]
        /// Returns the UIImage representation of the thumbnail. You need to explicitly link against UIKit to use this property.
        #[unsafe(method(UIImage))]
        #[unsafe(method_family = none)]
        pub unsafe fn UIImage(&self) -> Retained<UIImage>;

        #[cfg(feature = "objc2-app-kit")]
        #[cfg(target_os = "macos")]
        /// Returns the NSImage representation of the thumbnail. You need to explicitly link against AppKit to use this property.
        #[unsafe(method(NSImage))]
        #[unsafe(method_family = none)]
        pub unsafe fn NSImage(&self) -> Retained<NSImage>;

        #[cfg(feature = "objc2-core-foundation")]
        /// Returns the the effective rect within the thumbnail image representing the content of the document. In icon mode, this is the part of the image without all the image decorations.
        #[unsafe(method(contentRect))]
        #[unsafe(method_family = none)]
        pub unsafe fn contentRect(&self) -> CGRect;
    );
}

/// Methods declared on superclass `NSObject`.
impl QLThumbnailRepresentation {
    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>;
    );
}