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