1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CNContactType(pub NSInteger);
impl CNContactType {
    #[doc(alias = "CNContactTypePerson")]
    pub const Person: Self = Self(0);
    #[doc(alias = "CNContactTypeOrganization")]
    pub const Organization: Self = Self(1);
}

unsafe impl Encode for CNContactType {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

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

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CNContactSortOrder(pub NSInteger);
impl CNContactSortOrder {
    #[doc(alias = "CNContactSortOrderNone")]
    pub const None: Self = Self(0);
    #[doc(alias = "CNContactSortOrderUserDefault")]
    pub const UserDefault: Self = Self(1);
    #[doc(alias = "CNContactSortOrderGivenName")]
    pub const GivenName: Self = Self(2);
    #[doc(alias = "CNContactSortOrderFamilyName")]
    pub const FamilyName: Self = Self(3);
}

unsafe impl Encode for CNContactSortOrder {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

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

extern_protocol!(
    pub unsafe trait CNKeyDescriptor: NSCopying + NSObjectProtocol + NSSecureCoding {}

    unsafe impl ProtocolType for dyn CNKeyDescriptor {}
);

unsafe impl CNKeyDescriptor for NSString {}

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct CNContact;

    unsafe impl ClassType for CNContact {
        type Super = NSObject;
        type Mutability = InteriorMutable;
    }
);

unsafe impl NSCoding for CNContact {}

unsafe impl NSCopying for CNContact {}

unsafe impl NSMutableCopying for CNContact {}

unsafe impl NSObjectProtocol for CNContact {}

unsafe impl NSSecureCoding for CNContact {}

extern_methods!(
    unsafe impl CNContact {
        #[method_id(@__retain_semantics Other identifier)]
        pub unsafe fn identifier(&self) -> Retained<NSString>;

        #[method(contactType)]
        pub unsafe fn contactType(&self) -> CNContactType;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        #[method(imageDataAvailable)]
        pub unsafe fn imageDataAvailable(&self) -> bool;

        #[cfg(all(feature = "CNLabeledValue", feature = "CNPhoneNumber"))]
        #[method_id(@__retain_semantics Other phoneNumbers)]
        pub unsafe fn phoneNumbers(&self) -> Retained<NSArray<CNLabeledValue<CNPhoneNumber>>>;

        #[cfg(feature = "CNLabeledValue")]
        #[method_id(@__retain_semantics Other emailAddresses)]
        pub unsafe fn emailAddresses(&self) -> Retained<NSArray<CNLabeledValue<NSString>>>;

        #[cfg(all(feature = "CNLabeledValue", feature = "CNPostalAddress"))]
        #[method_id(@__retain_semantics Other postalAddresses)]
        pub unsafe fn postalAddresses(&self) -> Retained<NSArray<CNLabeledValue<CNPostalAddress>>>;

        #[cfg(feature = "CNLabeledValue")]
        #[method_id(@__retain_semantics Other urlAddresses)]
        pub unsafe fn urlAddresses(&self) -> Retained<NSArray<CNLabeledValue<NSString>>>;

        #[cfg(all(feature = "CNContactRelation", feature = "CNLabeledValue"))]
        #[method_id(@__retain_semantics Other contactRelations)]
        pub unsafe fn contactRelations(
            &self,
        ) -> Retained<NSArray<CNLabeledValue<CNContactRelation>>>;

        #[cfg(all(feature = "CNLabeledValue", feature = "CNSocialProfile"))]
        #[method_id(@__retain_semantics Other socialProfiles)]
        pub unsafe fn socialProfiles(&self) -> Retained<NSArray<CNLabeledValue<CNSocialProfile>>>;

        #[cfg(all(feature = "CNInstantMessageAddress", feature = "CNLabeledValue"))]
        #[method_id(@__retain_semantics Other instantMessageAddresses)]
        pub unsafe fn instantMessageAddresses(
            &self,
        ) -> Retained<NSArray<CNLabeledValue<CNInstantMessageAddress>>>;

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

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

        #[cfg(feature = "CNLabeledValue")]
        #[method_id(@__retain_semantics Other dates)]
        pub unsafe fn dates(&self) -> Retained<NSArray<CNLabeledValue<NSDateComponents>>>;

        #[method(isKeyAvailable:)]
        pub unsafe fn isKeyAvailable(&self, key: &NSString) -> bool;

        #[method(areKeysAvailable:)]
        pub unsafe fn areKeysAvailable(
            &self,
            key_descriptors: &NSArray<ProtocolObject<dyn CNKeyDescriptor>>,
        ) -> bool;

        #[method_id(@__retain_semantics Other localizedStringForKey:)]
        pub unsafe fn localizedStringForKey(key: &NSString) -> Retained<NSString>;

        #[cfg(feature = "block2")]
        #[method(comparatorForNameSortOrder:)]
        pub unsafe fn comparatorForNameSortOrder(sort_order: CNContactSortOrder) -> NSComparator;

        #[method_id(@__retain_semantics Other descriptorForAllComparatorKeys)]
        pub unsafe fn descriptorForAllComparatorKeys(
        ) -> Retained<ProtocolObject<dyn CNKeyDescriptor>>;

        #[method(isUnifiedWithContactWithIdentifier:)]
        pub unsafe fn isUnifiedWithContactWithIdentifier(
            &self,
            contact_identifier: &NSString,
        ) -> bool;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl CNContact {
        #[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 "C" {
    pub static CNContactPropertyNotFetchedExceptionName: &'static NSString;
}

extern "C" {
    pub static CNContactIdentifierKey: &'static NSString;
}

extern "C" {
    pub static CNContactNamePrefixKey: &'static NSString;
}

extern "C" {
    pub static CNContactGivenNameKey: &'static NSString;
}

extern "C" {
    pub static CNContactMiddleNameKey: &'static NSString;
}

extern "C" {
    pub static CNContactFamilyNameKey: &'static NSString;
}

extern "C" {
    pub static CNContactPreviousFamilyNameKey: &'static NSString;
}

extern "C" {
    pub static CNContactNameSuffixKey: &'static NSString;
}

extern "C" {
    pub static CNContactNicknameKey: &'static NSString;
}

extern "C" {
    pub static CNContactOrganizationNameKey: &'static NSString;
}

extern "C" {
    pub static CNContactDepartmentNameKey: &'static NSString;
}

extern "C" {
    pub static CNContactJobTitleKey: &'static NSString;
}

extern "C" {
    pub static CNContactPhoneticGivenNameKey: &'static NSString;
}

extern "C" {
    pub static CNContactPhoneticMiddleNameKey: &'static NSString;
}

extern "C" {
    pub static CNContactPhoneticFamilyNameKey: &'static NSString;
}

extern "C" {
    pub static CNContactPhoneticOrganizationNameKey: &'static NSString;
}

extern "C" {
    pub static CNContactBirthdayKey: &'static NSString;
}

extern "C" {
    pub static CNContactNonGregorianBirthdayKey: &'static NSString;
}

extern "C" {
    pub static CNContactNoteKey: &'static NSString;
}

extern "C" {
    pub static CNContactImageDataKey: &'static NSString;
}

extern "C" {
    pub static CNContactThumbnailImageDataKey: &'static NSString;
}

extern "C" {
    pub static CNContactImageDataAvailableKey: &'static NSString;
}

extern "C" {
    pub static CNContactTypeKey: &'static NSString;
}

extern "C" {
    pub static CNContactPhoneNumbersKey: &'static NSString;
}

extern "C" {
    pub static CNContactEmailAddressesKey: &'static NSString;
}

extern "C" {
    pub static CNContactPostalAddressesKey: &'static NSString;
}

extern "C" {
    pub static CNContactDatesKey: &'static NSString;
}

extern "C" {
    pub static CNContactUrlAddressesKey: &'static NSString;
}

extern "C" {
    pub static CNContactRelationsKey: &'static NSString;
}

extern "C" {
    pub static CNContactSocialProfilesKey: &'static NSString;
}

extern "C" {
    pub static CNContactInstantMessageAddressesKey: &'static NSString;
}