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

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

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

impl NSPersistentStore {
    extern_methods!(
        #[unsafe(method(metadataForPersistentStoreWithURL:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn metadataForPersistentStoreWithURL_error(
            url: &NSURL,
        ) -> Result<Retained<NSDictionary<NSString, AnyObject>>, Retained<NSError>>;

        /// # Safety
        ///
        /// `metadata` generic should be of the correct type.
        #[unsafe(method(setMetadata:forPersistentStoreWithURL:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn setMetadata_forPersistentStoreWithURL_error(
            metadata: Option<&NSDictionary<NSString, AnyObject>>,
            url: &NSURL,
        ) -> Result<(), Retained<NSError>>;

        #[unsafe(method(migrationManagerClass))]
        #[unsafe(method_family = none)]
        pub unsafe fn migrationManagerClass() -> &'static AnyClass;

        #[cfg(feature = "NSPersistentStoreCoordinator")]
        /// # Safety
        ///
        /// `options` generic should be of the correct type.
        #[unsafe(method(initWithPersistentStoreCoordinator:configurationName:URL:options:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithPersistentStoreCoordinator_configurationName_URL_options(
            this: Allocated<Self>,
            root: Option<&NSPersistentStoreCoordinator>,
            name: Option<&NSString>,
            url: &NSURL,
            options: Option<&NSDictionary>,
        ) -> Retained<Self>;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

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

        #[cfg(feature = "NSPersistentStoreCoordinator")]
        #[unsafe(method(persistentStoreCoordinator))]
        #[unsafe(method_family = none)]
        pub unsafe fn persistentStoreCoordinator(
            &self,
        ) -> Option<Retained<NSPersistentStoreCoordinator>>;

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

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

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

        /// Setter for [`URL`][Self::URL].
        #[unsafe(method(setURL:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setURL(&self, url: Option<&NSURL>);

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

        /// Setter for [`identifier`][Self::identifier].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setIdentifier:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setIdentifier(&self, identifier: Option<&NSString>);

        #[unsafe(method(type))]
        #[unsafe(method_family = none)]
        pub unsafe fn r#type(&self) -> Retained<NSString>;

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

        /// Setter for [`isReadOnly`][Self::isReadOnly].
        #[unsafe(method(setReadOnly:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setReadOnly(&self, read_only: bool);

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

        /// Setter for [`metadata`][Self::metadata].
        ///
        /// # Safety
        ///
        /// - `metadata` generic should be of the correct type.
        /// - `metadata` might not allow `None`.
        #[unsafe(method(setMetadata:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setMetadata(&self, metadata: Option<&NSDictionary<NSString, AnyObject>>);

        #[cfg(feature = "NSPersistentStoreCoordinator")]
        #[unsafe(method(didAddToPersistentStoreCoordinator:))]
        #[unsafe(method_family = none)]
        pub unsafe fn didAddToPersistentStoreCoordinator(
            &self,
            coordinator: &NSPersistentStoreCoordinator,
        );

        #[cfg(feature = "NSPersistentStoreCoordinator")]
        #[unsafe(method(willRemoveFromPersistentStoreCoordinator:))]
        #[unsafe(method_family = none)]
        pub unsafe fn willRemoveFromPersistentStoreCoordinator(
            &self,
            coordinator: Option<&NSPersistentStoreCoordinator>,
        );

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

/// Methods declared on superclass `NSObject`.
impl NSPersistentStore {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}