objc2-contacts 0.3.2

Bindings to the Contacts 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!(
    /// Specifies the search criteria to fetch contacts.
    ///
    ///
    /// Used with [CNContactStore enumerateContactsWithFetchRequest:error:usingBlock:]. Can combine any of these options to create a contact fetch request.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/contacts/cncontactfetchrequest?language=objc)
    #[unsafe(super(CNFetchRequest, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "CNFetchRequest")]
    pub struct CNContactFetchRequest;
);

#[cfg(feature = "CNFetchRequest")]
extern_conformance!(
    unsafe impl NSCoding for CNContactFetchRequest {}
);

#[cfg(feature = "CNFetchRequest")]
extern_conformance!(
    unsafe impl NSObjectProtocol for CNContactFetchRequest {}
);

#[cfg(feature = "CNFetchRequest")]
extern_conformance!(
    unsafe impl NSSecureCoding for CNContactFetchRequest {}
);

#[cfg(feature = "CNFetchRequest")]
impl CNContactFetchRequest {
    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>;

        #[cfg(feature = "CNContact")]
        /// Parameter `keysToFetch`: The properties to fetch for the returned contacts.
        ///
        ///
        /// Only fetch the properties that will be used.
        #[unsafe(method(initWithKeysToFetch:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithKeysToFetch(
            this: Allocated<Self>,
            keys_to_fetch: &NSArray<ProtocolObject<dyn CNKeyDescriptor>>,
        ) -> Retained<Self>;

        /// The predicate to match contacts against.
        ///
        ///
        /// Use only predicates from CNContact+Predicates.h. Compound predicates are not supported. Set to nil to match all contacts.
        #[unsafe(method(predicate))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicate(&self) -> Option<Retained<NSPredicate>>;

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

        #[cfg(feature = "CNContact")]
        /// The properties to fetch in the returned contacts.
        ///
        ///
        /// Should only fetch the properties that will be used. Can combine contact keys and contact key descriptors.
        #[unsafe(method(keysToFetch))]
        #[unsafe(method_family = none)]
        pub unsafe fn keysToFetch(&self) -> Retained<NSArray<ProtocolObject<dyn CNKeyDescriptor>>>;

        #[cfg(feature = "CNContact")]
        /// Setter for [`keysToFetch`][Self::keysToFetch].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setKeysToFetch:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setKeysToFetch(
            &self,
            keys_to_fetch: &NSArray<ProtocolObject<dyn CNKeyDescriptor>>,
        );

        /// To return mutable contacts.
        ///
        ///
        /// If YES returns CNMutableContact objects, otherwise returns CNContact objects. Default is NO.
        #[unsafe(method(mutableObjects))]
        #[unsafe(method_family = none)]
        pub unsafe fn mutableObjects(&self) -> bool;

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

        /// To return linked contacts as unified contacts.
        ///
        ///
        /// If YES returns unified contacts, otherwise returns individual contacts. Default is YES.
        ///
        ///
        /// Note: A unified contact is the aggregation of properties from a set of linked individual contacts. If an individual contact is not linked then the unified contact is simply that individual contact.
        #[unsafe(method(unifyResults))]
        #[unsafe(method_family = none)]
        pub unsafe fn unifyResults(&self) -> bool;

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

        #[cfg(feature = "CNContact")]
        /// To return contacts in a specific sort order.
        ///
        ///
        /// Default is CNContactSortOrderNone.
        #[unsafe(method(sortOrder))]
        #[unsafe(method_family = none)]
        pub unsafe fn sortOrder(&self) -> CNContactSortOrder;

        #[cfg(feature = "CNContact")]
        /// Setter for [`sortOrder`][Self::sortOrder].
        #[unsafe(method(setSortOrder:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setSortOrder(&self, sort_order: CNContactSortOrder);
    );
}