objc2_contacts/generated/
CNContact.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5use objc2_foundation::*;
6
7use crate::*;
8
9/// [Apple's documentation](https://developer.apple.com/documentation/contacts/cncontacttype?language=objc)
10// NS_ENUM
11#[repr(transparent)]
12#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
13pub struct CNContactType(pub NSInteger);
14impl CNContactType {
15    #[doc(alias = "CNContactTypePerson")]
16    pub const Person: Self = Self(0);
17    #[doc(alias = "CNContactTypeOrganization")]
18    pub const Organization: Self = Self(1);
19}
20
21unsafe impl Encode for CNContactType {
22    const ENCODING: Encoding = NSInteger::ENCODING;
23}
24
25unsafe impl RefEncode for CNContactType {
26    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
27}
28
29/// Sort order for contacts.
30///
31///
32/// CNContactSortOrderUserDefault is the user's preferred sort order.
33///
34/// See also [Apple's documentation](https://developer.apple.com/documentation/contacts/cncontactsortorder?language=objc)
35// NS_ENUM
36#[repr(transparent)]
37#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
38pub struct CNContactSortOrder(pub NSInteger);
39impl CNContactSortOrder {
40    #[doc(alias = "CNContactSortOrderNone")]
41    pub const None: Self = Self(0);
42    #[doc(alias = "CNContactSortOrderUserDefault")]
43    pub const UserDefault: Self = Self(1);
44    #[doc(alias = "CNContactSortOrderGivenName")]
45    pub const GivenName: Self = Self(2);
46    #[doc(alias = "CNContactSortOrderFamilyName")]
47    pub const FamilyName: Self = Self(3);
48}
49
50unsafe impl Encode for CNContactSortOrder {
51    const ENCODING: Encoding = NSInteger::ENCODING;
52}
53
54unsafe impl RefEncode for CNContactSortOrder {
55    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
56}
57
58extern_protocol!(
59    /// This protocol is reserved for Contacts framework usage.
60    ///
61    /// See also [Apple's documentation](https://developer.apple.com/documentation/contacts/cnkeydescriptor?language=objc)
62    pub unsafe trait CNKeyDescriptor: NSObjectProtocol + NSSecureCoding + NSCopying {}
63);
64
65extern_conformance!(
66    unsafe impl CNKeyDescriptor for NSString {}
67);
68
69extern_class!(
70    /// An immutable value object representing a contact.
71    ///
72    ///
73    /// CNContact is thread safe.
74    ///
75    /// If using a CNContact instance where you are not certain of the keys that were fetched, use isKeyAvailable: or areKeysAvailable:. If these return NO you need to refetch the contact by the contact identifier with the keys you want to fetch. Accessing a property that was not fetched will throw CNContactPropertyNotFetchedExceptionName.
76    ///
77    /// See also [Apple's documentation](https://developer.apple.com/documentation/contacts/cncontact?language=objc)
78    #[unsafe(super(NSObject))]
79    #[derive(Debug, PartialEq, Eq, Hash)]
80    pub struct CNContact;
81);
82
83extern_conformance!(
84    unsafe impl NSCoding for CNContact {}
85);
86
87extern_conformance!(
88    unsafe impl NSCopying for CNContact {}
89);
90
91unsafe impl CopyingHelper for CNContact {
92    type Result = Self;
93}
94
95extern_conformance!(
96    unsafe impl NSMutableCopying for CNContact {}
97);
98
99#[cfg(feature = "CNMutableContact")]
100unsafe impl MutableCopyingHelper for CNContact {
101    type Result = CNMutableContact;
102}
103
104extern_conformance!(
105    unsafe impl NSObjectProtocol for CNContact {}
106);
107
108extern_conformance!(
109    unsafe impl NSSecureCoding for CNContact {}
110);
111
112impl CNContact {
113    extern_methods!(
114        /// The identifier is unique among contacts on the device. It can be saved and used for fetching contacts next application launch.
115        #[unsafe(method(identifier))]
116        #[unsafe(method_family = none)]
117        pub unsafe fn identifier(&self) -> Retained<NSString>;
118
119        #[unsafe(method(contactType))]
120        #[unsafe(method_family = none)]
121        pub unsafe fn contactType(&self) -> CNContactType;
122
123        #[unsafe(method(namePrefix))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn namePrefix(&self) -> Retained<NSString>;
126
127        #[unsafe(method(givenName))]
128        #[unsafe(method_family = none)]
129        pub unsafe fn givenName(&self) -> Retained<NSString>;
130
131        #[unsafe(method(middleName))]
132        #[unsafe(method_family = none)]
133        pub unsafe fn middleName(&self) -> Retained<NSString>;
134
135        #[unsafe(method(familyName))]
136        #[unsafe(method_family = none)]
137        pub unsafe fn familyName(&self) -> Retained<NSString>;
138
139        #[unsafe(method(previousFamilyName))]
140        #[unsafe(method_family = none)]
141        pub unsafe fn previousFamilyName(&self) -> Retained<NSString>;
142
143        #[unsafe(method(nameSuffix))]
144        #[unsafe(method_family = none)]
145        pub unsafe fn nameSuffix(&self) -> Retained<NSString>;
146
147        #[unsafe(method(nickname))]
148        #[unsafe(method_family = none)]
149        pub unsafe fn nickname(&self) -> Retained<NSString>;
150
151        #[unsafe(method(organizationName))]
152        #[unsafe(method_family = none)]
153        pub unsafe fn organizationName(&self) -> Retained<NSString>;
154
155        #[unsafe(method(departmentName))]
156        #[unsafe(method_family = none)]
157        pub unsafe fn departmentName(&self) -> Retained<NSString>;
158
159        #[unsafe(method(jobTitle))]
160        #[unsafe(method_family = none)]
161        pub unsafe fn jobTitle(&self) -> Retained<NSString>;
162
163        #[unsafe(method(phoneticGivenName))]
164        #[unsafe(method_family = none)]
165        pub unsafe fn phoneticGivenName(&self) -> Retained<NSString>;
166
167        #[unsafe(method(phoneticMiddleName))]
168        #[unsafe(method_family = none)]
169        pub unsafe fn phoneticMiddleName(&self) -> Retained<NSString>;
170
171        #[unsafe(method(phoneticFamilyName))]
172        #[unsafe(method_family = none)]
173        pub unsafe fn phoneticFamilyName(&self) -> Retained<NSString>;
174
175        #[unsafe(method(phoneticOrganizationName))]
176        #[unsafe(method_family = none)]
177        pub unsafe fn phoneticOrganizationName(&self) -> Retained<NSString>;
178
179        #[unsafe(method(note))]
180        #[unsafe(method_family = none)]
181        pub unsafe fn note(&self) -> Retained<NSString>;
182
183        #[unsafe(method(imageData))]
184        #[unsafe(method_family = none)]
185        pub unsafe fn imageData(&self) -> Option<Retained<NSData>>;
186
187        #[unsafe(method(thumbnailImageData))]
188        #[unsafe(method_family = none)]
189        pub unsafe fn thumbnailImageData(&self) -> Option<Retained<NSData>>;
190
191        #[unsafe(method(imageDataAvailable))]
192        #[unsafe(method_family = none)]
193        pub unsafe fn imageDataAvailable(&self) -> bool;
194
195        #[cfg(all(feature = "CNLabeledValue", feature = "CNPhoneNumber"))]
196        #[unsafe(method(phoneNumbers))]
197        #[unsafe(method_family = none)]
198        pub unsafe fn phoneNumbers(&self) -> Retained<NSArray<CNLabeledValue<CNPhoneNumber>>>;
199
200        #[cfg(feature = "CNLabeledValue")]
201        #[unsafe(method(emailAddresses))]
202        #[unsafe(method_family = none)]
203        pub unsafe fn emailAddresses(&self) -> Retained<NSArray<CNLabeledValue<NSString>>>;
204
205        #[cfg(all(feature = "CNLabeledValue", feature = "CNPostalAddress"))]
206        #[unsafe(method(postalAddresses))]
207        #[unsafe(method_family = none)]
208        pub unsafe fn postalAddresses(&self) -> Retained<NSArray<CNLabeledValue<CNPostalAddress>>>;
209
210        #[cfg(feature = "CNLabeledValue")]
211        #[unsafe(method(urlAddresses))]
212        #[unsafe(method_family = none)]
213        pub unsafe fn urlAddresses(&self) -> Retained<NSArray<CNLabeledValue<NSString>>>;
214
215        #[cfg(all(feature = "CNContactRelation", feature = "CNLabeledValue"))]
216        #[unsafe(method(contactRelations))]
217        #[unsafe(method_family = none)]
218        pub unsafe fn contactRelations(
219            &self,
220        ) -> Retained<NSArray<CNLabeledValue<CNContactRelation>>>;
221
222        #[cfg(all(feature = "CNLabeledValue", feature = "CNSocialProfile"))]
223        #[unsafe(method(socialProfiles))]
224        #[unsafe(method_family = none)]
225        pub unsafe fn socialProfiles(&self) -> Retained<NSArray<CNLabeledValue<CNSocialProfile>>>;
226
227        #[cfg(all(feature = "CNInstantMessageAddress", feature = "CNLabeledValue"))]
228        #[unsafe(method(instantMessageAddresses))]
229        #[unsafe(method_family = none)]
230        pub unsafe fn instantMessageAddresses(
231            &self,
232        ) -> Retained<NSArray<CNLabeledValue<CNInstantMessageAddress>>>;
233
234        /// The Gregorian birthday.
235        #[unsafe(method(birthday))]
236        #[unsafe(method_family = none)]
237        pub unsafe fn birthday(&self) -> Option<Retained<NSDateComponents>>;
238
239        /// The alternate birthday (Lunisolar).
240        #[unsafe(method(nonGregorianBirthday))]
241        #[unsafe(method_family = none)]
242        pub unsafe fn nonGregorianBirthday(&self) -> Option<Retained<NSDateComponents>>;
243
244        #[cfg(feature = "CNLabeledValue")]
245        /// Other Gregorian dates (anniversaries, etc).
246        #[unsafe(method(dates))]
247        #[unsafe(method_family = none)]
248        pub unsafe fn dates(&self) -> Retained<NSArray<CNLabeledValue<NSDateComponents>>>;
249
250        /// Returns YES if the value for the specified key was fetched.
251        #[unsafe(method(isKeyAvailable:))]
252        #[unsafe(method_family = none)]
253        pub unsafe fn isKeyAvailable(&self, key: &NSString) -> bool;
254
255        /// Returns YES if the values for the keys specified by all the descriptors were fetched.
256        #[unsafe(method(areKeysAvailable:))]
257        #[unsafe(method_family = none)]
258        pub unsafe fn areKeysAvailable(
259            &self,
260            key_descriptors: &NSArray<ProtocolObject<dyn CNKeyDescriptor>>,
261        ) -> bool;
262
263        /// Returns a user displayable property name.
264        #[unsafe(method(localizedStringForKey:))]
265        #[unsafe(method_family = none)]
266        pub unsafe fn localizedStringForKey(key: &NSString) -> Retained<NSString>;
267
268        /// The contact comparator for a given sort order.
269        ///
270        /// # Safety
271        ///
272        /// - The returned block's argument 1 must be a valid pointer.
273        /// - The returned block's argument 2 must be a valid pointer.
274        #[unsafe(method(comparatorForNameSortOrder:))]
275        #[unsafe(method_family = none)]
276        pub unsafe fn comparatorForNameSortOrder(sort_order: CNContactSortOrder) -> NSComparator;
277
278        /// Use to fetch all contact keys required for the contact sort comparator.
279        #[unsafe(method(descriptorForAllComparatorKeys))]
280        #[unsafe(method_family = none)]
281        pub unsafe fn descriptorForAllComparatorKeys(
282        ) -> Retained<ProtocolObject<dyn CNKeyDescriptor>>;
283
284        /// Returns YES if the receiver was fetched as a unified contact and includes the contact having contactIdentifier in its unification
285        #[unsafe(method(isUnifiedWithContactWithIdentifier:))]
286        #[unsafe(method_family = none)]
287        pub unsafe fn isUnifiedWithContactWithIdentifier(
288            &self,
289            contact_identifier: &NSString,
290        ) -> bool;
291    );
292}
293
294/// Methods declared on superclass `NSObject`.
295impl CNContact {
296    extern_methods!(
297        #[unsafe(method(init))]
298        #[unsafe(method_family = init)]
299        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
300
301        #[unsafe(method(new))]
302        #[unsafe(method_family = new)]
303        pub unsafe fn new() -> Retained<Self>;
304    );
305}
306
307extern "C" {
308    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cncontactpropertynotfetchedexceptionname?language=objc)
309    pub static CNContactPropertyNotFetchedExceptionName: &'static NSString;
310}
311
312extern "C" {
313    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cncontactidentifierkey?language=objc)
314    pub static CNContactIdentifierKey: &'static NSString;
315}
316
317extern "C" {
318    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cncontactnameprefixkey?language=objc)
319    pub static CNContactNamePrefixKey: &'static NSString;
320}
321
322extern "C" {
323    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cncontactgivennamekey?language=objc)
324    pub static CNContactGivenNameKey: &'static NSString;
325}
326
327extern "C" {
328    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cncontactmiddlenamekey?language=objc)
329    pub static CNContactMiddleNameKey: &'static NSString;
330}
331
332extern "C" {
333    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cncontactfamilynamekey?language=objc)
334    pub static CNContactFamilyNameKey: &'static NSString;
335}
336
337extern "C" {
338    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cncontactpreviousfamilynamekey?language=objc)
339    pub static CNContactPreviousFamilyNameKey: &'static NSString;
340}
341
342extern "C" {
343    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cncontactnamesuffixkey?language=objc)
344    pub static CNContactNameSuffixKey: &'static NSString;
345}
346
347extern "C" {
348    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cncontactnicknamekey?language=objc)
349    pub static CNContactNicknameKey: &'static NSString;
350}
351
352extern "C" {
353    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cncontactorganizationnamekey?language=objc)
354    pub static CNContactOrganizationNameKey: &'static NSString;
355}
356
357extern "C" {
358    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cncontactdepartmentnamekey?language=objc)
359    pub static CNContactDepartmentNameKey: &'static NSString;
360}
361
362extern "C" {
363    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cncontactjobtitlekey?language=objc)
364    pub static CNContactJobTitleKey: &'static NSString;
365}
366
367extern "C" {
368    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cncontactphoneticgivennamekey?language=objc)
369    pub static CNContactPhoneticGivenNameKey: &'static NSString;
370}
371
372extern "C" {
373    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cncontactphoneticmiddlenamekey?language=objc)
374    pub static CNContactPhoneticMiddleNameKey: &'static NSString;
375}
376
377extern "C" {
378    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cncontactphoneticfamilynamekey?language=objc)
379    pub static CNContactPhoneticFamilyNameKey: &'static NSString;
380}
381
382extern "C" {
383    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cncontactphoneticorganizationnamekey?language=objc)
384    pub static CNContactPhoneticOrganizationNameKey: &'static NSString;
385}
386
387extern "C" {
388    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cncontactbirthdaykey?language=objc)
389    pub static CNContactBirthdayKey: &'static NSString;
390}
391
392extern "C" {
393    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cncontactnongregorianbirthdaykey?language=objc)
394    pub static CNContactNonGregorianBirthdayKey: &'static NSString;
395}
396
397extern "C" {
398    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cncontactnotekey?language=objc)
399    pub static CNContactNoteKey: &'static NSString;
400}
401
402extern "C" {
403    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cncontactimagedatakey?language=objc)
404    pub static CNContactImageDataKey: &'static NSString;
405}
406
407extern "C" {
408    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cncontactthumbnailimagedatakey?language=objc)
409    pub static CNContactThumbnailImageDataKey: &'static NSString;
410}
411
412extern "C" {
413    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cncontactimagedataavailablekey?language=objc)
414    pub static CNContactImageDataAvailableKey: &'static NSString;
415}
416
417extern "C" {
418    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cncontacttypekey?language=objc)
419    pub static CNContactTypeKey: &'static NSString;
420}
421
422extern "C" {
423    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cncontactphonenumberskey?language=objc)
424    pub static CNContactPhoneNumbersKey: &'static NSString;
425}
426
427extern "C" {
428    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cncontactemailaddresseskey?language=objc)
429    pub static CNContactEmailAddressesKey: &'static NSString;
430}
431
432extern "C" {
433    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cncontactpostaladdresseskey?language=objc)
434    pub static CNContactPostalAddressesKey: &'static NSString;
435}
436
437extern "C" {
438    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cncontactdateskey?language=objc)
439    pub static CNContactDatesKey: &'static NSString;
440}
441
442extern "C" {
443    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cncontacturladdresseskey?language=objc)
444    pub static CNContactUrlAddressesKey: &'static NSString;
445}
446
447extern "C" {
448    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cncontactrelationskey?language=objc)
449    pub static CNContactRelationsKey: &'static NSString;
450}
451
452extern "C" {
453    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cncontactsocialprofileskey?language=objc)
454    pub static CNContactSocialProfilesKey: &'static NSString;
455}
456
457extern "C" {
458    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cncontactinstantmessageaddresseskey?language=objc)
459    pub static CNContactInstantMessageAddressesKey: &'static NSString;
460}