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::*;
use objc2_foundation::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/photos/phassetresourcedatarequestid?language=objc)
pub type PHAssetResourceDataRequestID = i32;

/// [Apple's documentation](https://developer.apple.com/documentation/photos/phinvalidassetresourcedatarequestid?language=objc)
pub static PHInvalidAssetResourceDataRequestID: PHAssetResourceDataRequestID = 0;

/// [Apple's documentation](https://developer.apple.com/documentation/photos/phassetresourceprogresshandler?language=objc)
#[cfg(feature = "block2")]
pub type PHAssetResourceProgressHandler = *mut block2::DynBlock<dyn Fn(c_double)>;

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

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

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

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

impl PHAssetResourceRequestOptions {
    extern_methods!(
        #[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")]
        #[unsafe(method(progressHandler))]
        #[unsafe(method_family = none)]
        pub unsafe fn progressHandler(&self) -> PHAssetResourceProgressHandler;

        #[cfg(feature = "block2")]
        /// Setter for [`progressHandler`][Self::progressHandler].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        ///
        /// # Safety
        ///
        /// `progress_handler` must be a valid pointer or null.
        #[unsafe(method(setProgressHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setProgressHandler(&self, progress_handler: PHAssetResourceProgressHandler);
    );
}

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

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

unsafe impl Send for PHAssetResourceManager {}

unsafe impl Sync for PHAssetResourceManager {}

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

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

        #[cfg(all(feature = "PHAssetResource", feature = "block2"))]
        #[unsafe(method(requestDataForAssetResource:options:dataReceivedHandler:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn requestDataForAssetResource_options_dataReceivedHandler_completionHandler(
            &self,
            resource: &PHAssetResource,
            options: Option<&PHAssetResourceRequestOptions>,
            handler: &block2::DynBlock<dyn Fn(NonNull<NSData>)>,
            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
        ) -> PHAssetResourceDataRequestID;

        #[cfg(all(feature = "PHAssetResource", feature = "block2"))]
        #[unsafe(method(writeDataForAssetResource:toFile:options:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn writeDataForAssetResource_toFile_options_completionHandler(
            &self,
            resource: &PHAssetResource,
            file_url: &NSURL,
            options: Option<&PHAssetResourceRequestOptions>,
            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );

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

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