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
//! 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 changes to save.
///
///
/// Create a new save request for each save execution on the contact store. Can have many changes batched into one save request. Do not access objects in the save request when it is executing. A save request only applies the changes to the objects. If there are overlapping changes with multiple, concurrent CNSaveRequests then the last saved change wins.
///
/// If adding an object (contact, group, container) and it is already in the contact store then the executing save request will fail to add that object and will return the error CNErrorCodeInsertedRecordAlreadyExists with CNErrorUserInfoAffectedRecordsKey value as an array containing that object.
///
/// If updating/deleting an object (contact, group, container) and it is not in the contact store then the executing save request will fail to update/delete that object and will return the error CNErrorCodeRecordDoesNotExist with CNErrorUserInfoAffectedRecordsKey value as an array containing that object.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/contacts/cnsaverequest?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct CNSaveRequest;
);
extern_conformance!(
unsafe impl NSObjectProtocol for CNSaveRequest {}
);
impl CNSaveRequest {
extern_methods!(
#[cfg(all(feature = "CNContact", feature = "CNMutableContact"))]
/// Add a new contact to the contact store.
///
///
/// The contact may be modified by the executing save request. If the contact was previously specified to be deleted in the save request that will no longer occur.
///
///
/// Parameter `contact`: The new contact to add.
///
/// Parameter `identifier`: The container identifier to add the new contact to. Set to nil for the default container.
#[unsafe(method(addContact:toContainerWithIdentifier:))]
#[unsafe(method_family = none)]
pub unsafe fn addContact_toContainerWithIdentifier(
&self,
contact: &CNMutableContact,
identifier: Option<&NSString>,
);
#[cfg(all(feature = "CNContact", feature = "CNMutableContact"))]
/// Update an existing contact in the contact store.
///
///
/// The contact must already exist in the contact store. The contact may be modified by the executing save request.
#[unsafe(method(updateContact:))]
#[unsafe(method_family = none)]
pub unsafe fn updateContact(&self, contact: &CNMutableContact);
#[cfg(all(feature = "CNContact", feature = "CNMutableContact"))]
/// Delete a contact from the contact store.
///
///
/// If the contact was previously specified to be added in the save request that will no longer occur.
#[unsafe(method(deleteContact:))]
#[unsafe(method_family = none)]
pub unsafe fn deleteContact(&self, contact: &CNMutableContact);
#[cfg(all(feature = "CNGroup", feature = "CNMutableGroup"))]
/// Add a new group to the contact store.
///
///
/// If the group was previously specified to be deleted in the save request that will no longer occur.
///
///
/// Parameter `group`: The new group to add.
///
/// Parameter `identifier`: The container identifier to add the new group to. Set to nil for the default container.
#[unsafe(method(addGroup:toContainerWithIdentifier:))]
#[unsafe(method_family = none)]
pub unsafe fn addGroup_toContainerWithIdentifier(
&self,
group: &CNMutableGroup,
identifier: Option<&NSString>,
);
#[cfg(all(feature = "CNGroup", feature = "CNMutableGroup"))]
/// Update an existing group in the contact store.
///
///
/// The group must already exist in the contact store.
#[unsafe(method(updateGroup:))]
#[unsafe(method_family = none)]
pub unsafe fn updateGroup(&self, group: &CNMutableGroup);
#[cfg(all(feature = "CNGroup", feature = "CNMutableGroup"))]
/// Delete a group from the contact store.
///
///
/// The contacts in the group are not deleted. If the group was previously specified to be added in the save request that will no longer occur.
#[unsafe(method(deleteGroup:))]
#[unsafe(method_family = none)]
pub unsafe fn deleteGroup(&self, group: &CNMutableGroup);
#[cfg(feature = "CNGroup")]
/// Add a new subgroup to a group.
///
///
/// If the subgroup was previously specified to be deleted in the save request that will no longer occur.
///
///
/// Parameter `subgroup`: The new group to add.
///
/// Parameter `group`: The group to add the subgroup to.
#[unsafe(method(addSubgroup:toGroup:))]
#[unsafe(method_family = none)]
pub unsafe fn addSubgroup_toGroup(&self, subgroup: &CNGroup, group: &CNGroup);
#[cfg(feature = "CNGroup")]
/// Remove a subgroup from a group.
///
///
/// The contacts in the subgroup's membership are not affected. If the subgroup was previously specified to be added in the save request that will no longer occur.
///
///
/// Parameter `subgroup`: The new group to add.
///
/// Parameter `group`: The group to add the subgroup to.
#[unsafe(method(removeSubgroup:fromGroup:))]
#[unsafe(method_family = none)]
pub unsafe fn removeSubgroup_fromGroup(&self, subgroup: &CNGroup, group: &CNGroup);
#[cfg(all(feature = "CNContact", feature = "CNGroup"))]
/// Add a new member to a group.
///
///
/// If the membership was previously specified to be deleted in the save request that will no longer occur.
///
///
/// Parameter `contact`: The new member to add to the group.
///
/// Parameter `group`: The group to add the member to.
#[unsafe(method(addMember:toGroup:))]
#[unsafe(method_family = none)]
pub unsafe fn addMember_toGroup(&self, contact: &CNContact, group: &CNGroup);
#[cfg(all(feature = "CNContact", feature = "CNGroup"))]
/// Remove a member from a group.
///
///
/// The contact is not deleted. It is only removed as a member of the group. If the membership was previously specified to be added in the save request that will no longer occur.
///
///
/// Parameter `contact`: The member to remove from the group.
///
/// Parameter `group`: The group to remove the member from.
#[unsafe(method(removeMember:fromGroup:))]
#[unsafe(method_family = none)]
pub unsafe fn removeMember_fromGroup(&self, contact: &CNContact, group: &CNGroup);
/// The author of this transaction.
///
///
/// Use this, in conjunction with
/// `CNChangeHistoryFetchRequest.excludedTransactionAuthors,`to suppress fetching of changes the author already knows about.
#[unsafe(method(transactionAuthor))]
#[unsafe(method_family = none)]
pub unsafe fn transactionAuthor(&self) -> Option<Retained<NSString>>;
/// Setter for [`transactionAuthor`][Self::transactionAuthor].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
#[unsafe(method(setTransactionAuthor:))]
#[unsafe(method_family = none)]
pub unsafe fn setTransactionAuthor(&self, transaction_author: Option<&NSString>);
/// Should the contacts be refetched as part of executing the save request.
///
///
/// Default is `YES` where added and updated contacts are refetched by the executing save request.
/// Set to `NO` to suppress this refetch behavior and reduce the execution time of the save request.
///
///
/// Note: If set to `NO` do not use the contacts after the executed save request as they may not be in a current state.
#[unsafe(method(shouldRefetchContacts))]
#[unsafe(method_family = none)]
pub unsafe fn shouldRefetchContacts(&self) -> bool;
/// Setter for [`shouldRefetchContacts`][Self::shouldRefetchContacts].
#[unsafe(method(setShouldRefetchContacts:))]
#[unsafe(method_family = none)]
pub unsafe fn setShouldRefetchContacts(&self, should_refetch_contacts: bool);
);
}
/// Methods declared on superclass `NSObject`.
impl CNSaveRequest {
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>;
);
}