objc2-core-data 0.3.2

Bindings to the CoreData 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/coredata/nssnapshoteventtype?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSSnapshotEventType(pub NSUInteger);
bitflags::bitflags! {
    impl NSSnapshotEventType: NSUInteger {
        #[doc(alias = "NSSnapshotEventUndoInsertion")]
        const UndoInsertion = 1<<1;
        #[doc(alias = "NSSnapshotEventUndoDeletion")]
        const UndoDeletion = 1<<2;
        #[doc(alias = "NSSnapshotEventUndoUpdate")]
        const UndoUpdate = 1<<3;
        #[doc(alias = "NSSnapshotEventRollback")]
        const Rollback = 1<<4;
        #[doc(alias = "NSSnapshotEventRefresh")]
        const Refresh = 1<<5;
        #[doc(alias = "NSSnapshotEventMergePolicy")]
        const MergePolicy = 1<<6;
    }
}

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

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

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

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

impl NSManagedObject {
    extern_methods!(
        #[unsafe(method(contextShouldIgnoreUnmodeledPropertyChanges))]
        #[unsafe(method_family = none)]
        pub unsafe fn contextShouldIgnoreUnmodeledPropertyChanges() -> bool;

        #[cfg(feature = "NSEntityDescription")]
        #[unsafe(method(entity))]
        #[unsafe(method_family = none)]
        pub unsafe fn entity_class() -> Retained<NSEntityDescription>;

        #[cfg(all(feature = "NSFetchRequest", feature = "NSPersistentStoreRequest"))]
        #[unsafe(method(fetchRequest))]
        #[unsafe(method_family = none)]
        pub unsafe fn fetchRequest() -> Retained<NSFetchRequest>;

        #[cfg(all(feature = "NSEntityDescription", feature = "NSManagedObjectContext"))]
        #[unsafe(method(initWithEntity:insertIntoManagedObjectContext:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithEntity_insertIntoManagedObjectContext(
            this: Allocated<Self>,
            entity: &NSEntityDescription,
            context: Option<&NSManagedObjectContext>,
        ) -> Retained<NSManagedObject>;

        #[cfg(feature = "NSManagedObjectContext")]
        #[unsafe(method(initWithContext:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithContext(
            this: Allocated<Self>,
            moc: &NSManagedObjectContext,
        ) -> Retained<Self>;

        #[cfg(feature = "NSManagedObjectContext")]
        /// # Safety
        ///
        /// This is not retained internally, you must ensure the object is still alive.
        #[unsafe(method(managedObjectContext))]
        #[unsafe(method_family = none)]
        pub unsafe fn managedObjectContext(&self) -> Option<Retained<NSManagedObjectContext>>;

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

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

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

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

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

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

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

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

        #[unsafe(method(hasFaultForRelationshipNamed:))]
        #[unsafe(method_family = none)]
        pub unsafe fn hasFaultForRelationshipNamed(&self, key: &NSString) -> bool;

        #[cfg(feature = "NSManagedObjectID")]
        #[unsafe(method(objectIDsForRelationshipNamed:))]
        #[unsafe(method_family = none)]
        pub unsafe fn objectIDsForRelationshipNamed(
            &self,
            key: &NSString,
        ) -> Retained<NSArray<NSManagedObjectID>>;

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

        #[unsafe(method(willAccessValueForKey:))]
        #[unsafe(method_family = none)]
        pub unsafe fn willAccessValueForKey(&self, key: Option<&NSString>);

        #[unsafe(method(didAccessValueForKey:))]
        #[unsafe(method_family = none)]
        pub unsafe fn didAccessValueForKey(&self, key: Option<&NSString>);

        #[unsafe(method(willChangeValueForKey:))]
        #[unsafe(method_family = none)]
        pub unsafe fn willChangeValueForKey(&self, key: &NSString);

        #[unsafe(method(didChangeValueForKey:))]
        #[unsafe(method_family = none)]
        pub unsafe fn didChangeValueForKey(&self, key: &NSString);

        /// # Safety
        ///
        /// `in_objects` generic should be of the correct type.
        #[unsafe(method(willChangeValueForKey:withSetMutation:usingObjects:))]
        #[unsafe(method_family = none)]
        pub unsafe fn willChangeValueForKey_withSetMutation_usingObjects(
            &self,
            in_key: &NSString,
            in_mutation_kind: NSKeyValueSetMutationKind,
            in_objects: &NSSet,
        );

        /// # Safety
        ///
        /// `in_objects` generic should be of the correct type.
        #[unsafe(method(didChangeValueForKey:withSetMutation:usingObjects:))]
        #[unsafe(method_family = none)]
        pub unsafe fn didChangeValueForKey_withSetMutation_usingObjects(
            &self,
            in_key: &NSString,
            in_mutation_kind: NSKeyValueSetMutationKind,
            in_objects: &NSSet,
        );

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

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

        #[unsafe(method(awakeFromSnapshotEvents:))]
        #[unsafe(method_family = none)]
        pub unsafe fn awakeFromSnapshotEvents(&self, flags: NSSnapshotEventType);

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

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

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

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

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

        #[unsafe(method(valueForKey:))]
        #[unsafe(method_family = none)]
        pub unsafe fn valueForKey(&self, key: &NSString) -> Option<Retained<AnyObject>>;

        /// # Safety
        ///
        /// `value` should be of the correct type.
        #[unsafe(method(setValue:forKey:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setValue_forKey(&self, value: Option<&AnyObject>, key: &NSString);

        #[unsafe(method(primitiveValueForKey:))]
        #[unsafe(method_family = none)]
        pub unsafe fn primitiveValueForKey(&self, key: &NSString) -> Option<Retained<AnyObject>>;

        /// # Safety
        ///
        /// `value` should be of the correct type.
        #[unsafe(method(setPrimitiveValue:forKey:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPrimitiveValue_forKey(&self, value: Option<&AnyObject>, key: &NSString);

        #[unsafe(method(committedValuesForKeys:))]
        #[unsafe(method_family = none)]
        pub unsafe fn committedValuesForKeys(
            &self,
            keys: Option<&NSArray<NSString>>,
        ) -> Retained<NSDictionary<NSString, AnyObject>>;

        #[unsafe(method(changedValues))]
        #[unsafe(method_family = none)]
        pub unsafe fn changedValues(&self) -> Retained<NSDictionary<NSString, AnyObject>>;

        #[unsafe(method(changedValuesForCurrentEvent))]
        #[unsafe(method_family = none)]
        pub unsafe fn changedValuesForCurrentEvent(
            &self,
        ) -> Retained<NSDictionary<NSString, AnyObject>>;

        /// # Safety
        ///
        /// `value` should be of the correct type.
        #[unsafe(method(validateValue:forKey:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn validateValue_forKey_error(
            &self,
            value: &mut Option<Retained<AnyObject>>,
            key: &NSString,
        ) -> Result<(), Retained<NSError>>;

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

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

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

        /// # Safety
        ///
        /// `in_observation_info` must be a valid pointer or null.
        #[unsafe(method(setObservationInfo:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setObservationInfo(&self, in_observation_info: *mut c_void);

        #[unsafe(method(observationInfo))]
        #[unsafe(method_family = none)]
        pub unsafe fn observationInfo(&self) -> *mut c_void;
    );
}

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