objc2-core-data 0.2.2

Bindings to the CoreData framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

__inner_extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NSFetchedResultsController<ResultType: ?Sized = AnyObject> {
        __superclass: NSObject,
        _inner0: PhantomData<*mut ResultType>,
        notunwindsafe: PhantomData<&'static mut ()>,
    }

    unsafe impl<ResultType: ?Sized + Message> ClassType for NSFetchedResultsController<ResultType> {
        type Super = NSObject;
        type Mutability = InteriorMutable;

        fn as_super(&self) -> &Self::Super {
            &self.__superclass
        }

        fn as_super_mut(&mut self) -> &mut Self::Super {
            &mut self.__superclass
        }
    }
);

unsafe impl<ResultType: ?Sized> NSObjectProtocol for NSFetchedResultsController<ResultType> {}

extern_methods!(
    unsafe impl<ResultType: Message> NSFetchedResultsController<ResultType> {
        #[cfg(all(
            feature = "NSFetchRequest",
            feature = "NSManagedObjectContext",
            feature = "NSPersistentStoreRequest"
        ))]
        #[method_id(@__retain_semantics Init initWithFetchRequest:managedObjectContext:sectionNameKeyPath:cacheName:)]
        pub unsafe fn initWithFetchRequest_managedObjectContext_sectionNameKeyPath_cacheName(
            this: Allocated<Self>,
            fetch_request: &NSFetchRequest<ResultType>,
            context: &NSManagedObjectContext,
            section_name_key_path: Option<&NSString>,
            name: Option<&NSString>,
        ) -> Retained<Self>;

        #[method(performFetch:_)]
        pub unsafe fn performFetch(&self) -> Result<(), Retained<NSError>>;

        #[cfg(all(feature = "NSFetchRequest", feature = "NSPersistentStoreRequest"))]
        #[method_id(@__retain_semantics Other fetchRequest)]
        pub unsafe fn fetchRequest(&self) -> Retained<NSFetchRequest<ResultType>>;

        #[cfg(feature = "NSManagedObjectContext")]
        #[method_id(@__retain_semantics Other managedObjectContext)]
        pub unsafe fn managedObjectContext(&self) -> Retained<NSManagedObjectContext>;

        #[method_id(@__retain_semantics Other sectionNameKeyPath)]
        pub unsafe fn sectionNameKeyPath(&self) -> Option<Retained<NSString>>;

        #[method_id(@__retain_semantics Other cacheName)]
        pub unsafe fn cacheName(&self) -> Option<Retained<NSString>>;

        #[method_id(@__retain_semantics Other delegate)]
        pub unsafe fn delegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn NSFetchedResultsControllerDelegate>>>;

        #[method(setDelegate:)]
        pub unsafe fn setDelegate(
            &self,
            delegate: Option<&ProtocolObject<dyn NSFetchedResultsControllerDelegate>>,
        );

        #[method(deleteCacheWithName:)]
        pub unsafe fn deleteCacheWithName(name: Option<&NSString>);

        #[method_id(@__retain_semantics Other fetchedObjects)]
        pub unsafe fn fetchedObjects(&self) -> Option<Retained<NSArray<ResultType>>>;

        #[method_id(@__retain_semantics Other objectAtIndexPath:)]
        pub unsafe fn objectAtIndexPath(&self, index_path: &NSIndexPath) -> Retained<ResultType>;

        #[method_id(@__retain_semantics Other indexPathForObject:)]
        pub unsafe fn indexPathForObject(
            &self,
            object: &ResultType,
        ) -> Option<Retained<NSIndexPath>>;

        #[method_id(@__retain_semantics Other sectionIndexTitleForSectionName:)]
        pub unsafe fn sectionIndexTitleForSectionName(
            &self,
            section_name: &NSString,
        ) -> Option<Retained<NSString>>;

        #[method_id(@__retain_semantics Other sectionIndexTitles)]
        pub unsafe fn sectionIndexTitles(&self) -> Retained<NSArray<NSString>>;

        #[method_id(@__retain_semantics Other sections)]
        pub unsafe fn sections(
            &self,
        ) -> Option<Retained<NSArray<ProtocolObject<dyn NSFetchedResultsSectionInfo>>>>;

        #[method(sectionForSectionIndexTitle:atIndex:)]
        pub unsafe fn sectionForSectionIndexTitle_atIndex(
            &self,
            title: &NSString,
            section_index: NSInteger,
        ) -> NSInteger;
    }
);

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

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

extern_protocol!(
    pub unsafe trait NSFetchedResultsSectionInfo {
        #[method_id(@__retain_semantics Other name)]
        unsafe fn name(&self) -> Retained<NSString>;

        #[method_id(@__retain_semantics Other indexTitle)]
        unsafe fn indexTitle(&self) -> Option<Retained<NSString>>;

        #[method(numberOfObjects)]
        unsafe fn numberOfObjects(&self) -> NSUInteger;

        #[method_id(@__retain_semantics Other objects)]
        unsafe fn objects(&self) -> Option<Retained<NSArray>>;
    }

    unsafe impl ProtocolType for dyn NSFetchedResultsSectionInfo {}
);

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSFetchedResultsChangeType(pub NSUInteger);
impl NSFetchedResultsChangeType {
    pub const NSFetchedResultsChangeInsert: Self = Self(1);
    pub const NSFetchedResultsChangeDelete: Self = Self(2);
    pub const NSFetchedResultsChangeMove: Self = Self(3);
    pub const NSFetchedResultsChangeUpdate: Self = Self(4);
}

unsafe impl Encode for NSFetchedResultsChangeType {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

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

extern_protocol!(
    pub unsafe trait NSFetchedResultsControllerDelegate: NSObjectProtocol {
        #[cfg(feature = "NSManagedObjectID")]
        #[optional]
        #[method(controller:didChangeContentWithDifference:)]
        unsafe fn controller_didChangeContentWithDifference(
            &self,
            controller: &NSFetchedResultsController,
            diff: &NSOrderedCollectionDifference<NSManagedObjectID>,
        );

        #[optional]
        #[method(controller:didChangeObject:atIndexPath:forChangeType:newIndexPath:)]
        unsafe fn controller_didChangeObject_atIndexPath_forChangeType_newIndexPath(
            &self,
            controller: &NSFetchedResultsController,
            an_object: &AnyObject,
            index_path: Option<&NSIndexPath>,
            r#type: NSFetchedResultsChangeType,
            new_index_path: Option<&NSIndexPath>,
        );

        #[optional]
        #[method(controller:didChangeSection:atIndex:forChangeType:)]
        unsafe fn controller_didChangeSection_atIndex_forChangeType(
            &self,
            controller: &NSFetchedResultsController,
            section_info: &ProtocolObject<dyn NSFetchedResultsSectionInfo>,
            section_index: NSUInteger,
            r#type: NSFetchedResultsChangeType,
        );

        #[optional]
        #[method(controllerWillChangeContent:)]
        unsafe fn controllerWillChangeContent(&self, controller: &NSFetchedResultsController);

        #[optional]
        #[method(controllerDidChangeContent:)]
        unsafe fn controllerDidChangeContent(&self, controller: &NSFetchedResultsController);

        #[optional]
        #[method_id(@__retain_semantics Other controller:sectionIndexTitleForSectionName:)]
        unsafe fn controller_sectionIndexTitleForSectionName(
            &self,
            controller: &NSFetchedResultsController,
            section_name: &NSString,
        ) -> Option<Retained<NSString>>;
    }

    unsafe impl ProtocolType for dyn NSFetchedResultsControllerDelegate {}
);