objc2-photos 0.2.0

Bindings to the Photos/PhotoKit framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
#[cfg(feature = "block2")]
use block2::*;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct PHAuthorizationStatus(pub NSInteger);
impl PHAuthorizationStatus {
    #[doc(alias = "PHAuthorizationStatusNotDetermined")]
    pub const NotDetermined: Self = Self(0);
    #[doc(alias = "PHAuthorizationStatusRestricted")]
    pub const Restricted: Self = Self(1);
    #[doc(alias = "PHAuthorizationStatusDenied")]
    pub const Denied: Self = Self(2);
    #[doc(alias = "PHAuthorizationStatusAuthorized")]
    pub const Authorized: Self = Self(3);
    #[doc(alias = "PHAuthorizationStatusLimited")]
    pub const Limited: Self = Self(4);
}

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

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

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct PHAccessLevel(pub NSInteger);
impl PHAccessLevel {
    #[doc(alias = "PHAccessLevelAddOnly")]
    pub const AddOnly: Self = Self(1);
    #[doc(alias = "PHAccessLevelReadWrite")]
    pub const ReadWrite: Self = Self(2);
}

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

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

extern_protocol!(
    pub unsafe trait PHPhotoLibraryChangeObserver: NSObjectProtocol {
        #[cfg(feature = "PHChange")]
        #[method(photoLibraryDidChange:)]
        unsafe fn photoLibraryDidChange(&self, change_instance: &PHChange);
    }

    unsafe impl ProtocolType for dyn PHPhotoLibraryChangeObserver {}
);

extern_protocol!(
    pub unsafe trait PHPhotoLibraryAvailabilityObserver: NSObjectProtocol {
        #[method(photoLibraryDidBecomeUnavailable:)]
        unsafe fn photoLibraryDidBecomeUnavailable(&self, photo_library: &PHPhotoLibrary);
    }

    unsafe impl ProtocolType for dyn PHPhotoLibraryAvailabilityObserver {}
);

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct PHPhotoLibrary;

    unsafe impl ClassType for PHPhotoLibrary {
        type Super = NSObject;
        type Mutability = InteriorMutable;
    }
);

unsafe impl Send for PHPhotoLibrary {}

unsafe impl Sync for PHPhotoLibrary {}

unsafe impl NSObjectProtocol for PHPhotoLibrary {}

extern_methods!(
    unsafe impl PHPhotoLibrary {
        #[method_id(@__retain_semantics Other sharedPhotoLibrary)]
        pub unsafe fn sharedPhotoLibrary() -> Id<PHPhotoLibrary>;

        #[method(authorizationStatusForAccessLevel:)]
        pub unsafe fn authorizationStatusForAccessLevel(
            access_level: PHAccessLevel,
        ) -> PHAuthorizationStatus;

        #[cfg(feature = "block2")]
        #[method(requestAuthorizationForAccessLevel:handler:)]
        pub unsafe fn requestAuthorizationForAccessLevel_handler(
            access_level: PHAccessLevel,
            handler: &Block<dyn Fn(PHAuthorizationStatus)>,
        );

        #[deprecated]
        #[method(authorizationStatus)]
        pub unsafe fn authorizationStatus() -> PHAuthorizationStatus;

        #[cfg(feature = "block2")]
        #[deprecated]
        #[method(requestAuthorization:)]
        pub unsafe fn requestAuthorization(handler: &Block<dyn Fn(PHAuthorizationStatus)>);

        #[method_id(@__retain_semantics Other unavailabilityReason)]
        pub unsafe fn unavailabilityReason(&self) -> Option<Id<NSError>>;

        #[method(registerAvailabilityObserver:)]
        pub unsafe fn registerAvailabilityObserver(
            &self,
            observer: &ProtocolObject<dyn PHPhotoLibraryAvailabilityObserver>,
        );

        #[method(unregisterAvailabilityObserver:)]
        pub unsafe fn unregisterAvailabilityObserver(
            &self,
            observer: &ProtocolObject<dyn PHPhotoLibraryAvailabilityObserver>,
        );

        #[method(registerChangeObserver:)]
        pub unsafe fn registerChangeObserver(
            &self,
            observer: &ProtocolObject<dyn PHPhotoLibraryChangeObserver>,
        );

        #[method(unregisterChangeObserver:)]
        pub unsafe fn unregisterChangeObserver(
            &self,
            observer: &ProtocolObject<dyn PHPhotoLibraryChangeObserver>,
        );

        #[cfg(all(
            feature = "PHPersistentChangeFetchResult",
            feature = "PHPersistentChangeToken"
        ))]
        #[method_id(@__retain_semantics Other fetchPersistentChangesSinceToken:error:_)]
        pub unsafe fn fetchPersistentChangesSinceToken_error(
            &self,
            token: &PHPersistentChangeToken,
        ) -> Result<Id<PHPersistentChangeFetchResult>, Id<NSError>>;

        #[cfg(feature = "PHPersistentChangeToken")]
        #[method_id(@__retain_semantics Other currentChangeToken)]
        pub unsafe fn currentChangeToken(&self) -> Id<PHPersistentChangeToken>;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl PHPhotoLibrary {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Id<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Id<Self>;
    }
);