objc2-photos 0.3.2

Bindings to the Photos/PhotoKit 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-app-kit")]
#[cfg(target_os = "macos")]
use objc2_app_kit::*;
#[cfg(feature = "objc2-core-location")]
use objc2_core_location::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/photos/phassetchangerequest?language=objc)
    #[unsafe(super(PHChangeRequest, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "PHChangeRequest")]
    pub struct PHAssetChangeRequest;
);

#[cfg(feature = "PHChangeRequest")]
extern_conformance!(
    unsafe impl NSObjectProtocol for PHAssetChangeRequest {}
);

#[cfg(feature = "PHChangeRequest")]
impl PHAssetChangeRequest {
    extern_methods!(
        #[cfg(feature = "objc2-app-kit")]
        #[cfg(target_os = "macos")]
        #[unsafe(method(creationRequestForAssetFromImage:))]
        #[unsafe(method_family = none)]
        pub unsafe fn creationRequestForAssetFromImage(image: &NSImage) -> Retained<Self>;

        #[unsafe(method(creationRequestForAssetFromImageAtFileURL:))]
        #[unsafe(method_family = none)]
        pub unsafe fn creationRequestForAssetFromImageAtFileURL(
            file_url: &NSURL,
        ) -> Option<Retained<Self>>;

        #[unsafe(method(creationRequestForAssetFromVideoAtFileURL:))]
        #[unsafe(method_family = none)]
        pub unsafe fn creationRequestForAssetFromVideoAtFileURL(
            file_url: &NSURL,
        ) -> Option<Retained<Self>>;

        #[cfg(feature = "PHObject")]
        #[unsafe(method(placeholderForCreatedAsset))]
        #[unsafe(method_family = none)]
        pub unsafe fn placeholderForCreatedAsset(&self) -> Option<Retained<PHObjectPlaceholder>>;

        /// # Safety
        ///
        /// `assets` should be of the correct type.
        #[unsafe(method(deleteAssets:))]
        #[unsafe(method_family = none)]
        pub unsafe fn deleteAssets(assets: &ProtocolObject<dyn NSFastEnumeration>);

        #[cfg(all(feature = "PHAsset", feature = "PHObject"))]
        #[unsafe(method(changeRequestForAsset:))]
        #[unsafe(method_family = none)]
        pub unsafe fn changeRequestForAsset(asset: &PHAsset) -> Retained<Self>;

        #[unsafe(method(creationDate))]
        #[unsafe(method_family = none)]
        pub unsafe fn creationDate(&self) -> Option<Retained<NSDate>>;

        /// Setter for [`creationDate`][Self::creationDate].
        #[unsafe(method(setCreationDate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setCreationDate(&self, creation_date: Option<&NSDate>);

        #[cfg(feature = "objc2-core-location")]
        #[unsafe(method(location))]
        #[unsafe(method_family = none)]
        pub unsafe fn location(&self) -> Option<Retained<CLLocation>>;

        #[cfg(feature = "objc2-core-location")]
        /// Setter for [`location`][Self::location].
        #[unsafe(method(setLocation:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setLocation(&self, location: Option<&CLLocation>);

        #[unsafe(method(isFavorite))]
        #[unsafe(method_family = none)]
        pub unsafe fn isFavorite(&self) -> bool;

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

        #[unsafe(method(isHidden))]
        #[unsafe(method_family = none)]
        pub unsafe fn isHidden(&self) -> bool;

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

        #[cfg(feature = "PHContentEditingOutput")]
        #[unsafe(method(contentEditingOutput))]
        #[unsafe(method_family = none)]
        pub unsafe fn contentEditingOutput(&self) -> Option<Retained<PHContentEditingOutput>>;

        #[cfg(feature = "PHContentEditingOutput")]
        /// Setter for [`contentEditingOutput`][Self::contentEditingOutput].
        #[unsafe(method(setContentEditingOutput:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setContentEditingOutput(
            &self,
            content_editing_output: Option<&PHContentEditingOutput>,
        );

        #[unsafe(method(revertAssetContentToOriginal))]
        #[unsafe(method_family = none)]
        pub unsafe fn revertAssetContentToOriginal(&self);
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "PHChangeRequest")]
impl PHAssetChangeRequest {
    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>;
    );
}

/// [Apple's documentation](https://developer.apple.com/documentation/photos/phcontenteditinginputrequestid?language=objc)
pub type PHContentEditingInputRequestID = NSUInteger;

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

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

impl PHContentEditingInputRequestOptions {
    extern_methods!(
        #[cfg(all(feature = "PHAdjustmentData", feature = "block2"))]
        /// # Safety
        ///
        /// The returned block's argument must be a valid pointer.
        #[unsafe(method(canHandleAdjustmentData))]
        #[unsafe(method_family = none)]
        pub unsafe fn canHandleAdjustmentData(
            &self,
        ) -> NonNull<block2::DynBlock<dyn Fn(NonNull<PHAdjustmentData>) -> Bool>>;

        #[cfg(all(feature = "PHAdjustmentData", feature = "block2"))]
        /// Setter for [`canHandleAdjustmentData`][Self::canHandleAdjustmentData].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setCanHandleAdjustmentData:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setCanHandleAdjustmentData(
            &self,
            can_handle_adjustment_data: &block2::DynBlock<
                dyn Fn(NonNull<PHAdjustmentData>) -> Bool,
            >,
        );

        #[unsafe(method(isNetworkAccessAllowed))]
        #[unsafe(method_family = none)]
        pub unsafe fn isNetworkAccessAllowed(&self) -> bool;

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

        #[cfg(feature = "block2")]
        /// # Safety
        ///
        /// The returned block's argument 2 must be a valid pointer.
        #[unsafe(method(progressHandler))]
        #[unsafe(method_family = none)]
        pub unsafe fn progressHandler(
            &self,
        ) -> *mut block2::DynBlock<dyn Fn(c_double, NonNull<Bool>)>;

        #[cfg(feature = "block2")]
        /// Setter for [`progressHandler`][Self::progressHandler].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setProgressHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setProgressHandler(
            &self,
            progress_handler: Option<&block2::DynBlock<dyn Fn(c_double, NonNull<Bool>)>>,
        );
    );
}

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

/// PHContentEditingInput.
#[cfg(all(feature = "PHAsset", feature = "PHObject"))]
impl PHAsset {
    extern_methods!(
        #[cfg(all(feature = "PHContentEditingInput", feature = "block2"))]
        #[unsafe(method(requestContentEditingInputWithOptions:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn requestContentEditingInputWithOptions_completionHandler(
            &self,
            options: Option<&PHContentEditingInputRequestOptions>,
            completion_handler: &block2::DynBlock<
                dyn Fn(*mut PHContentEditingInput, NonNull<NSDictionary>),
            >,
        ) -> PHContentEditingInputRequestID;

        #[unsafe(method(cancelContentEditingInputRequest:))]
        #[unsafe(method_family = none)]
        pub unsafe fn cancelContentEditingInputRequest(
            &self,
            request_id: PHContentEditingInputRequestID,
        );
    );
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/photos/phcontenteditinginputresultisincloudkey?language=objc)
    pub static PHContentEditingInputResultIsInCloudKey: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/photos/phcontenteditinginputcancelledkey?language=objc)
    pub static PHContentEditingInputCancelledKey: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/photos/phcontenteditinginputerrorkey?language=objc)
    pub static PHContentEditingInputErrorKey: &'static NSString;
}

/// PHAssetChangeRequest.
#[cfg(feature = "PHContentEditingOutput")]
impl PHContentEditingOutput {
    extern_methods!(
        #[cfg(feature = "PHObject")]
        #[unsafe(method(initWithPlaceholderForCreatedAsset:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithPlaceholderForCreatedAsset(
            this: Allocated<Self>,
            placeholder_for_created_asset: &PHObjectPlaceholder,
        ) -> Retained<Self>;
    );
}