objc2-contacts 0.3.2

Bindings to the Contacts framework
Documentation
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
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
//! 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!(
    /// A mutable value object representing a contact.
    ///
    ///
    /// CNMutableContact is not thread safe. If this is a mutable copy of CNContact then it will throw CNContactPropertyNotFetchedExceptionName when accessing a property that was not fetched for the CNContact.
    ///
    ///
    /// Note: To remove properties when saving a mutable contact, set string properties and array properties to empty values. Set other properties to nil.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/contacts/cnmutablecontact?language=objc)
    #[unsafe(super(CNContact, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "CNContact")]
    pub struct CNMutableContact;
);

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

#[cfg(feature = "CNContact")]
extern_conformance!(
    unsafe impl NSCopying for CNMutableContact {}
);

#[cfg(feature = "CNContact")]
unsafe impl CopyingHelper for CNMutableContact {
    type Result = CNContact;
}

#[cfg(feature = "CNContact")]
extern_conformance!(
    unsafe impl NSMutableCopying for CNMutableContact {}
);

#[cfg(feature = "CNContact")]
unsafe impl MutableCopyingHelper for CNMutableContact {
    type Result = Self;
}

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

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

#[cfg(feature = "CNContact")]
impl CNMutableContact {
    extern_methods!(
        #[unsafe(method(contactType))]
        #[unsafe(method_family = none)]
        pub unsafe fn contactType(&self) -> CNContactType;

        /// Setter for [`contactType`][Self::contactType].
        #[unsafe(method(setContactType:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setContactType(&self, contact_type: CNContactType);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        #[cfg(all(feature = "CNLabeledValue", feature = "CNPhoneNumber"))]
        #[unsafe(method(phoneNumbers))]
        #[unsafe(method_family = none)]
        pub unsafe fn phoneNumbers(&self) -> Retained<NSArray<CNLabeledValue<CNPhoneNumber>>>;

        #[cfg(all(feature = "CNLabeledValue", feature = "CNPhoneNumber"))]
        /// Setter for [`phoneNumbers`][Self::phoneNumbers].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setPhoneNumbers:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPhoneNumbers(
            &self,
            phone_numbers: &NSArray<CNLabeledValue<CNPhoneNumber>>,
        );

        #[cfg(feature = "CNLabeledValue")]
        #[unsafe(method(emailAddresses))]
        #[unsafe(method_family = none)]
        pub unsafe fn emailAddresses(&self) -> Retained<NSArray<CNLabeledValue<NSString>>>;

        #[cfg(feature = "CNLabeledValue")]
        /// Setter for [`emailAddresses`][Self::emailAddresses].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setEmailAddresses:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setEmailAddresses(&self, email_addresses: &NSArray<CNLabeledValue<NSString>>);

        #[cfg(all(feature = "CNLabeledValue", feature = "CNPostalAddress"))]
        #[unsafe(method(postalAddresses))]
        #[unsafe(method_family = none)]
        pub unsafe fn postalAddresses(&self) -> Retained<NSArray<CNLabeledValue<CNPostalAddress>>>;

        #[cfg(all(feature = "CNLabeledValue", feature = "CNPostalAddress"))]
        /// Setter for [`postalAddresses`][Self::postalAddresses].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setPostalAddresses:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPostalAddresses(
            &self,
            postal_addresses: &NSArray<CNLabeledValue<CNPostalAddress>>,
        );

        #[cfg(feature = "CNLabeledValue")]
        #[unsafe(method(urlAddresses))]
        #[unsafe(method_family = none)]
        pub unsafe fn urlAddresses(&self) -> Retained<NSArray<CNLabeledValue<NSString>>>;

        #[cfg(feature = "CNLabeledValue")]
        /// Setter for [`urlAddresses`][Self::urlAddresses].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setUrlAddresses:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setUrlAddresses(&self, url_addresses: &NSArray<CNLabeledValue<NSString>>);

        #[cfg(all(feature = "CNContactRelation", feature = "CNLabeledValue"))]
        #[unsafe(method(contactRelations))]
        #[unsafe(method_family = none)]
        pub unsafe fn contactRelations(
            &self,
        ) -> Retained<NSArray<CNLabeledValue<CNContactRelation>>>;

        #[cfg(all(feature = "CNContactRelation", feature = "CNLabeledValue"))]
        /// Setter for [`contactRelations`][Self::contactRelations].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setContactRelations:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setContactRelations(
            &self,
            contact_relations: &NSArray<CNLabeledValue<CNContactRelation>>,
        );

        #[cfg(all(feature = "CNLabeledValue", feature = "CNSocialProfile"))]
        #[unsafe(method(socialProfiles))]
        #[unsafe(method_family = none)]
        pub unsafe fn socialProfiles(&self) -> Retained<NSArray<CNLabeledValue<CNSocialProfile>>>;

        #[cfg(all(feature = "CNLabeledValue", feature = "CNSocialProfile"))]
        /// Setter for [`socialProfiles`][Self::socialProfiles].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setSocialProfiles:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setSocialProfiles(
            &self,
            social_profiles: &NSArray<CNLabeledValue<CNSocialProfile>>,
        );

        #[cfg(all(feature = "CNInstantMessageAddress", feature = "CNLabeledValue"))]
        #[unsafe(method(instantMessageAddresses))]
        #[unsafe(method_family = none)]
        pub unsafe fn instantMessageAddresses(
            &self,
        ) -> Retained<NSArray<CNLabeledValue<CNInstantMessageAddress>>>;

        #[cfg(all(feature = "CNInstantMessageAddress", feature = "CNLabeledValue"))]
        /// Setter for [`instantMessageAddresses`][Self::instantMessageAddresses].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setInstantMessageAddresses:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setInstantMessageAddresses(
            &self,
            instant_message_addresses: &NSArray<CNLabeledValue<CNInstantMessageAddress>>,
        );

        /// The Gregorian birthday.
        ///
        /// Only uses day, month and year components. Needs to have at least a day and a month.
        #[unsafe(method(birthday))]
        #[unsafe(method_family = none)]
        pub unsafe fn birthday(&self) -> Option<Retained<NSDateComponents>>;

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

        /// The alternate birthday (Lunisolar).
        ///
        /// Only uses day, month, year and calendar components. Needs to have at least a day and a month. Calendar must be Chinese, Hebrew or Islamic.
        #[unsafe(method(nonGregorianBirthday))]
        #[unsafe(method_family = none)]
        pub unsafe fn nonGregorianBirthday(&self) -> Option<Retained<NSDateComponents>>;

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

        #[cfg(feature = "CNLabeledValue")]
        /// Other Gregorian dates (anniversaries, etc).
        ///
        /// Only uses day, month and year components. Needs to have at least a day and a month.
        #[unsafe(method(dates))]
        #[unsafe(method_family = none)]
        pub unsafe fn dates(&self) -> Retained<NSArray<CNLabeledValue<NSDateComponents>>>;

        #[cfg(feature = "CNLabeledValue")]
        /// Setter for [`dates`][Self::dates].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setDates:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDates(&self, dates: &NSArray<CNLabeledValue<NSDateComponents>>);
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "CNContact")]
impl CNMutableContact {
    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>;
    );
}