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

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

unsafe impl Send for PHChange {}

unsafe impl Sync for PHChange {}

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

impl PHChange {
    extern_methods!(
        #[cfg(feature = "PHObject")]
        #[unsafe(method(changeDetailsForObject:))]
        #[unsafe(method_family = none)]
        pub unsafe fn changeDetailsForObject(
            &self,
            object: &PHObject,
        ) -> Option<Retained<PHObjectChangeDetails>>;

        #[cfg(all(feature = "PHFetchResult", feature = "PHObject"))]
        /// # Safety
        ///
        /// `object` generic should be of the correct type.
        #[unsafe(method(changeDetailsForFetchResult:))]
        #[unsafe(method_family = none)]
        pub unsafe fn changeDetailsForFetchResult(
            &self,
            object: &PHFetchResult,
        ) -> Option<Retained<PHFetchResultChangeDetails>>;
    );
}

/// Methods declared on superclass `NSObject`.
impl PHChange {
    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/phobjectchangedetails?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "PHObject")]
    pub struct PHObjectChangeDetails<ObjectType: ?Sized = AnyObject>;
);

#[cfg(feature = "PHObject")]
impl<ObjectType: ?Sized + Message + AsRef<PHObject>> PHObjectChangeDetails<ObjectType> {
    /// Unchecked conversion of the generic parameter.
    ///
    /// # Safety
    ///
    /// The generic must be valid to reinterpret as the given type.
    #[inline]
    pub unsafe fn cast_unchecked<NewObjectType: ?Sized + Message + AsRef<PHObject>>(
        &self,
    ) -> &PHObjectChangeDetails<NewObjectType> {
        unsafe { &*((self as *const Self).cast()) }
    }
}

#[cfg(feature = "PHObject")]
extern_conformance!(
    unsafe impl<ObjectType: ?Sized + AsRef<PHObject>> NSObjectProtocol
        for PHObjectChangeDetails<ObjectType>
    {
    }
);

#[cfg(feature = "PHObject")]
impl<ObjectType: Message + AsRef<PHObject>> PHObjectChangeDetails<ObjectType> {
    extern_methods!(
        #[unsafe(method(objectBeforeChanges))]
        #[unsafe(method_family = none)]
        pub unsafe fn objectBeforeChanges(&self) -> Retained<ObjectType>;

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

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

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

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "PHObject")]
impl<ObjectType: Message + AsRef<PHObject>> PHObjectChangeDetails<ObjectType> {
    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/phfetchresultchangedetails?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "PHObject")]
    pub struct PHFetchResultChangeDetails<ObjectType: ?Sized = AnyObject>;
);

#[cfg(feature = "PHObject")]
impl<ObjectType: ?Sized + Message + AsRef<PHObject>> PHFetchResultChangeDetails<ObjectType> {
    /// Unchecked conversion of the generic parameter.
    ///
    /// # Safety
    ///
    /// The generic must be valid to reinterpret as the given type.
    #[inline]
    pub unsafe fn cast_unchecked<NewObjectType: ?Sized + Message + AsRef<PHObject>>(
        &self,
    ) -> &PHFetchResultChangeDetails<NewObjectType> {
        unsafe { &*((self as *const Self).cast()) }
    }
}

#[cfg(feature = "PHObject")]
extern_conformance!(
    unsafe impl<ObjectType: ?Sized + AsRef<PHObject>> NSObjectProtocol
        for PHFetchResultChangeDetails<ObjectType>
    {
    }
);

#[cfg(feature = "PHObject")]
impl<ObjectType: Message + AsRef<PHObject>> PHFetchResultChangeDetails<ObjectType> {
    extern_methods!(
        #[cfg(feature = "PHFetchResult")]
        #[unsafe(method(fetchResultBeforeChanges))]
        #[unsafe(method_family = none)]
        pub unsafe fn fetchResultBeforeChanges(&self) -> Retained<PHFetchResult<ObjectType>>;

        #[cfg(feature = "PHFetchResult")]
        #[unsafe(method(fetchResultAfterChanges))]
        #[unsafe(method_family = none)]
        pub unsafe fn fetchResultAfterChanges(&self) -> Retained<PHFetchResult<ObjectType>>;

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

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

        #[unsafe(method(removedObjects))]
        #[unsafe(method_family = none)]
        pub unsafe fn removedObjects(&self) -> Retained<NSArray<ObjectType>>;

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

        #[unsafe(method(insertedObjects))]
        #[unsafe(method_family = none)]
        pub unsafe fn insertedObjects(&self) -> Retained<NSArray<ObjectType>>;

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

        #[unsafe(method(changedObjects))]
        #[unsafe(method_family = none)]
        pub unsafe fn changedObjects(&self) -> Retained<NSArray<ObjectType>>;

        #[cfg(feature = "block2")]
        #[unsafe(method(enumerateMovesWithBlock:))]
        #[unsafe(method_family = none)]
        pub unsafe fn enumerateMovesWithBlock(
            &self,
            handler: &block2::DynBlock<dyn Fn(NSUInteger, NSUInteger)>,
        );

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

        #[cfg(feature = "PHFetchResult")]
        #[unsafe(method(changeDetailsFromFetchResult:toFetchResult:changedObjects:))]
        #[unsafe(method_family = none)]
        pub unsafe fn changeDetailsFromFetchResult_toFetchResult_changedObjects(
            from_result: &PHFetchResult<ObjectType>,
            to_result: &PHFetchResult<ObjectType>,
            changed_objects: &NSArray<ObjectType>,
        ) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "PHObject")]
impl<ObjectType: Message + AsRef<PHObject>> PHFetchResultChangeDetails<ObjectType> {
    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>;
    );
}