objc2_contacts/generated/CNSaveRequest.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_class!(
11 /// Specifies the changes to save.
12 ///
13 ///
14 /// 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.
15 ///
16 /// 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.
17 ///
18 /// 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.
19 ///
20 /// See also [Apple's documentation](https://developer.apple.com/documentation/contacts/cnsaverequest?language=objc)
21 #[unsafe(super(NSObject))]
22 #[derive(Debug, PartialEq, Eq, Hash)]
23 pub struct CNSaveRequest;
24);
25
26unsafe impl NSObjectProtocol for CNSaveRequest {}
27
28impl CNSaveRequest {
29 extern_methods!(
30 #[cfg(all(feature = "CNContact", feature = "CNMutableContact"))]
31 /// Add a new contact to the contact store.
32 ///
33 ///
34 /// 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.
35 ///
36 ///
37 /// Parameter `contact`: The new contact to add.
38 ///
39 /// Parameter `identifier`: The container identifier to add the new contact to. Set to nil for the default container.
40 #[unsafe(method(addContact:toContainerWithIdentifier:))]
41 #[unsafe(method_family = none)]
42 pub unsafe fn addContact_toContainerWithIdentifier(
43 &self,
44 contact: &CNMutableContact,
45 identifier: Option<&NSString>,
46 );
47
48 #[cfg(all(feature = "CNContact", feature = "CNMutableContact"))]
49 /// Update an existing contact in the contact store.
50 ///
51 ///
52 /// The contact must already exist in the contact store. The contact may be modified by the executing save request.
53 #[unsafe(method(updateContact:))]
54 #[unsafe(method_family = none)]
55 pub unsafe fn updateContact(&self, contact: &CNMutableContact);
56
57 #[cfg(all(feature = "CNContact", feature = "CNMutableContact"))]
58 /// Delete a contact from the contact store.
59 ///
60 ///
61 /// If the contact was previously specified to be added in the save request that will no longer occur.
62 #[unsafe(method(deleteContact:))]
63 #[unsafe(method_family = none)]
64 pub unsafe fn deleteContact(&self, contact: &CNMutableContact);
65
66 #[cfg(all(feature = "CNGroup", feature = "CNMutableGroup"))]
67 /// Add a new group to the contact store.
68 ///
69 ///
70 /// If the group was previously specified to be deleted in the save request that will no longer occur.
71 ///
72 ///
73 /// Parameter `group`: The new group to add.
74 ///
75 /// Parameter `identifier`: The container identifier to add the new group to. Set to nil for the default container.
76 #[unsafe(method(addGroup:toContainerWithIdentifier:))]
77 #[unsafe(method_family = none)]
78 pub unsafe fn addGroup_toContainerWithIdentifier(
79 &self,
80 group: &CNMutableGroup,
81 identifier: Option<&NSString>,
82 );
83
84 #[cfg(all(feature = "CNGroup", feature = "CNMutableGroup"))]
85 /// Update an existing group in the contact store.
86 ///
87 ///
88 /// The group must already exist in the contact store.
89 #[unsafe(method(updateGroup:))]
90 #[unsafe(method_family = none)]
91 pub unsafe fn updateGroup(&self, group: &CNMutableGroup);
92
93 #[cfg(all(feature = "CNGroup", feature = "CNMutableGroup"))]
94 /// Delete a group from the contact store.
95 ///
96 ///
97 /// 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.
98 #[unsafe(method(deleteGroup:))]
99 #[unsafe(method_family = none)]
100 pub unsafe fn deleteGroup(&self, group: &CNMutableGroup);
101
102 #[cfg(feature = "CNGroup")]
103 /// Add a new subgroup to a group.
104 ///
105 ///
106 /// If the subgroup was previously specified to be deleted in the save request that will no longer occur.
107 ///
108 ///
109 /// Parameter `subgroup`: The new group to add.
110 ///
111 /// Parameter `group`: The group to add the subgroup to.
112 #[unsafe(method(addSubgroup:toGroup:))]
113 #[unsafe(method_family = none)]
114 pub unsafe fn addSubgroup_toGroup(&self, subgroup: &CNGroup, group: &CNGroup);
115
116 #[cfg(feature = "CNGroup")]
117 /// Remove a subgroup from a group.
118 ///
119 ///
120 /// 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.
121 ///
122 ///
123 /// Parameter `subgroup`: The new group to add.
124 ///
125 /// Parameter `group`: The group to add the subgroup to.
126 #[unsafe(method(removeSubgroup:fromGroup:))]
127 #[unsafe(method_family = none)]
128 pub unsafe fn removeSubgroup_fromGroup(&self, subgroup: &CNGroup, group: &CNGroup);
129
130 #[cfg(all(feature = "CNContact", feature = "CNGroup"))]
131 /// Add a new member to a group.
132 ///
133 ///
134 /// If the membership was previously specified to be deleted in the save request that will no longer occur.
135 ///
136 ///
137 /// Parameter `contact`: The new member to add to the group.
138 ///
139 /// Parameter `group`: The group to add the member to.
140 #[unsafe(method(addMember:toGroup:))]
141 #[unsafe(method_family = none)]
142 pub unsafe fn addMember_toGroup(&self, contact: &CNContact, group: &CNGroup);
143
144 #[cfg(all(feature = "CNContact", feature = "CNGroup"))]
145 /// Remove a member from a group.
146 ///
147 ///
148 /// 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.
149 ///
150 ///
151 /// Parameter `contact`: The member to remove from the group.
152 ///
153 /// Parameter `group`: The group to remove the member from.
154 #[unsafe(method(removeMember:fromGroup:))]
155 #[unsafe(method_family = none)]
156 pub unsafe fn removeMember_fromGroup(&self, contact: &CNContact, group: &CNGroup);
157
158 /// The author of this transaction.
159 ///
160 ///
161 /// Use this, in conjunction with
162 /// `CNChangeHistoryFetchRequest.excludedTransactionAuthors,`to suppress fetching of changes the author already knows about.
163 #[unsafe(method(transactionAuthor))]
164 #[unsafe(method_family = none)]
165 pub unsafe fn transactionAuthor(&self) -> Option<Retained<NSString>>;
166
167 /// Setter for [`transactionAuthor`][Self::transactionAuthor].
168 #[unsafe(method(setTransactionAuthor:))]
169 #[unsafe(method_family = none)]
170 pub unsafe fn setTransactionAuthor(&self, transaction_author: Option<&NSString>);
171
172 /// Should the contacts be refetched as part of executing the save request.
173 ///
174 ///
175 /// Default is `YES` where added and updated contacts are refetched by the executing save request.
176 /// Set to `NO` to suppress this refetch behavior and reduce the execution time of the save request.
177 ///
178 ///
179 /// Note: If set to `NO` do not use the contacts after the executed save request as they may not be in a current state.
180 #[unsafe(method(shouldRefetchContacts))]
181 #[unsafe(method_family = none)]
182 pub unsafe fn shouldRefetchContacts(&self) -> bool;
183
184 /// Setter for [`shouldRefetchContacts`][Self::shouldRefetchContacts].
185 #[unsafe(method(setShouldRefetchContacts:))]
186 #[unsafe(method_family = none)]
187 pub unsafe fn setShouldRefetchContacts(&self, should_refetch_contacts: bool);
188 );
189}
190
191/// Methods declared on superclass `NSObject`.
192impl CNSaveRequest {
193 extern_methods!(
194 #[unsafe(method(init))]
195 #[unsafe(method_family = init)]
196 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
197
198 #[unsafe(method(new))]
199 #[unsafe(method_family = new)]
200 pub unsafe fn new() -> Retained<Self>;
201 );
202}