objc2_authentication_services/generated/ASCredentialIdentityStore.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 "C" {
11 /// [Apple's documentation](https://developer.apple.com/documentation/authenticationservices/ascredentialidentitystoreerrordomain?language=objc)
12 pub static ASCredentialIdentityStoreErrorDomain: &'static NSErrorDomain;
13}
14
15/// [Apple's documentation](https://developer.apple.com/documentation/authenticationservices/ascredentialidentitystoreerrorcode?language=objc)
16// NS_ERROR_ENUM
17#[repr(transparent)]
18#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
19pub struct ASCredentialIdentityStoreErrorCode(pub NSInteger);
20impl ASCredentialIdentityStoreErrorCode {
21 #[doc(alias = "ASCredentialIdentityStoreErrorCodeInternalError")]
22 pub const InternalError: Self = Self(0);
23 #[doc(alias = "ASCredentialIdentityStoreErrorCodeStoreDisabled")]
24 pub const StoreDisabled: Self = Self(1);
25 #[doc(alias = "ASCredentialIdentityStoreErrorCodeStoreBusy")]
26 pub const StoreBusy: Self = Self(2);
27}
28
29unsafe impl Encode for ASCredentialIdentityStoreErrorCode {
30 const ENCODING: Encoding = NSInteger::ENCODING;
31}
32
33unsafe impl RefEncode for ASCredentialIdentityStoreErrorCode {
34 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
35}
36
37/// [Apple's documentation](https://developer.apple.com/documentation/authenticationservices/ascredentialidentitytypes?language=objc)
38// NS_OPTIONS
39#[repr(transparent)]
40#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
41pub struct ASCredentialIdentityTypes(pub NSUInteger);
42bitflags::bitflags! {
43 impl ASCredentialIdentityTypes: NSUInteger {
44 #[doc(alias = "ASCredentialIdentityTypesAll")]
45 const All = 0;
46 #[doc(alias = "ASCredentialIdentityTypesPassword")]
47 const Password = 1;
48 #[doc(alias = "ASCredentialIdentityTypesPasskey")]
49 const Passkey = 1<<1;
50 #[doc(alias = "ASCredentialIdentityTypesOneTimeCode")]
51 const OneTimeCode = 1<<2;
52 }
53}
54
55unsafe impl Encode for ASCredentialIdentityTypes {
56 const ENCODING: Encoding = NSUInteger::ENCODING;
57}
58
59unsafe impl RefEncode for ASCredentialIdentityTypes {
60 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
61}
62
63extern_class!(
64 /// [Apple's documentation](https://developer.apple.com/documentation/authenticationservices/ascredentialidentitystore?language=objc)
65 #[unsafe(super(NSObject))]
66 #[derive(Debug, PartialEq, Eq, Hash)]
67 pub struct ASCredentialIdentityStore;
68);
69
70extern_conformance!(
71 unsafe impl NSObjectProtocol for ASCredentialIdentityStore {}
72);
73
74impl ASCredentialIdentityStore {
75 extern_methods!(
76 #[unsafe(method(sharedStore))]
77 #[unsafe(method_family = none)]
78 pub unsafe fn sharedStore() -> Retained<ASCredentialIdentityStore>;
79
80 #[unsafe(method(init))]
81 #[unsafe(method_family = init)]
82 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
83
84 #[cfg(all(feature = "ASCredentialIdentityStoreState", feature = "block2"))]
85 /// Get the state of the credential identity store.
86 ///
87 /// Parameter `completion`: completion handler to be called with the current state of the store.
88 ///
89 /// Call this method to find out the current state of the store before attempting to call other store methods.
90 /// Use the provided ASCredentialIdentityStoreState to find out if the store is enabled and whether it supports incremental
91 /// updates.
92 #[unsafe(method(getCredentialIdentityStoreStateWithCompletion:))]
93 #[unsafe(method_family = none)]
94 pub unsafe fn getCredentialIdentityStoreStateWithCompletion(
95 &self,
96 completion: &block2::DynBlock<dyn Fn(NonNull<ASCredentialIdentityStoreState>)>,
97 );
98
99 #[cfg(all(
100 feature = "ASCredentialIdentity",
101 feature = "ASCredentialServiceIdentifier",
102 feature = "block2"
103 ))]
104 /// List the currently saved credential identities.
105 ///
106 /// Parameter `serviceIdentifier`: Specify a service identifier to get only credential identities for that service.
107 /// Pass nil to get credential identities for all services.
108 ///
109 /// Parameter `credentialIdentityTypes`: Specify one or more types to get only credential identities of those types.
110 /// Pass ASCredentialIdentityTypesAll to get credential identities of all types.
111 ///
112 /// Call this method to get a list of all credential identities saved in the store for your extension.
113 #[unsafe(method(getCredentialIdentitiesForService:credentialIdentityTypes:completionHandler:))]
114 #[unsafe(method_family = none)]
115 pub unsafe fn getCredentialIdentitiesForService_credentialIdentityTypes_completionHandler(
116 &self,
117 service_identifier: Option<&ASCredentialServiceIdentifier>,
118 credential_identity_types: ASCredentialIdentityTypes,
119 completion_handler: &block2::DynBlock<
120 dyn Fn(NonNull<NSArray<ProtocolObject<dyn ASCredentialIdentity>>>),
121 >,
122 );
123
124 #[cfg(all(feature = "ASPasswordCredentialIdentity", feature = "block2"))]
125 /// Save the given credential identities to the store.
126 ///
127 /// Parameter `credentialIdentities`: array of ASPasswordCredentialIdentity objects to save to the store.
128 ///
129 /// Parameter `completion`: optional completion handler to be called after adding the credential identities.
130 /// If the operation fails, an error with domain ASCredentialIdentityStoreErrorDomain will be provided
131 /// and none of the objects in credentialIdentities will be saved to the store.
132 ///
133 /// If the store supports incremental updates, call this method to add new credential
134 /// identities since the last time the store was updated. Otherwise, call this method to pass all credential
135 /// identities.
136 /// If some credential identities in credentialIdentities already exist in the store, they will be replaced by
137 /// those from credentialIdentities.
138 #[deprecated]
139 #[unsafe(method(saveCredentialIdentities:completion:))]
140 #[unsafe(method_family = none)]
141 pub unsafe fn saveCredentialIdentities_completion(
142 &self,
143 credential_identities: &NSArray<ASPasswordCredentialIdentity>,
144 completion: Option<&block2::DynBlock<dyn Fn(Bool, *mut NSError)>>,
145 );
146
147 #[cfg(all(feature = "ASCredentialIdentity", feature = "block2"))]
148 /// Save the given credential identities to the store.
149 ///
150 /// Parameter `credentialIdentities`: array of ASCredentialIdentity objects to save to the store.
151 ///
152 /// Parameter `completion`: optional completion handler to be called after adding the credential identities.
153 /// If the operation fails, an error with domain ASCredentialIdentityStoreErrorDomain will be provided
154 /// and none of the objects in credentialIdentities will be saved to the store.
155 ///
156 /// If the store supports incremental updates, call this method to add new credential
157 /// identities since the last time the store was updated. Otherwise, call this method to pass all credential
158 /// identities.
159 /// If some credential identities in credentialIdentities already exist in the store, they will be replaced by
160 /// those from credentialIdentities.
161 #[unsafe(method(saveCredentialIdentityEntries:completion:))]
162 #[unsafe(method_family = none)]
163 pub unsafe fn saveCredentialIdentityEntries_completion(
164 &self,
165 credential_identities: &NSArray<ProtocolObject<dyn ASCredentialIdentity>>,
166 completion: Option<&block2::DynBlock<dyn Fn(Bool, *mut NSError)>>,
167 );
168
169 #[cfg(all(feature = "ASPasswordCredentialIdentity", feature = "block2"))]
170 /// Remove the given credential identities from the store.
171 ///
172 /// Parameter `credentialIdentities`: array of ASPasswordCredentialIdentity objects to remove from the store.
173 ///
174 /// Parameter `completion`: optional completion handler to be called after removing the credential identities.
175 /// If the operation fails, an error with domain ASCredentialIdentityStoreErrorDomain will be provided
176 /// and none of the objects in credentialIdentities will be removed from the store.
177 ///
178 /// Use this method only if the store supports incremental updates to remove previously added
179 /// credentials to the store.
180 #[deprecated]
181 #[unsafe(method(removeCredentialIdentities:completion:))]
182 #[unsafe(method_family = none)]
183 pub unsafe fn removeCredentialIdentities_completion(
184 &self,
185 credential_identities: &NSArray<ASPasswordCredentialIdentity>,
186 completion: Option<&block2::DynBlock<dyn Fn(Bool, *mut NSError)>>,
187 );
188
189 #[cfg(all(feature = "ASCredentialIdentity", feature = "block2"))]
190 /// Remove the given credential identities from the store.
191 ///
192 /// Parameter `credentialIdentities`: array of ASCredentialIdentity objects to remove from the store.
193 ///
194 /// Parameter `completion`: optional completion handler to be called after removing the credential identities.
195 /// If the operation fails, an error with domain ASCredentialIdentityStoreErrorDomain will be provided
196 /// and none of the objects in credentialIdentities will be removed from the store.
197 ///
198 /// Use this method only if the store supports incremental updates to remove previously added
199 /// credentials to the store.
200 #[unsafe(method(removeCredentialIdentityEntries:completion:))]
201 #[unsafe(method_family = none)]
202 pub unsafe fn removeCredentialIdentityEntries_completion(
203 &self,
204 credential_identities: &NSArray<ProtocolObject<dyn ASCredentialIdentity>>,
205 completion: Option<&block2::DynBlock<dyn Fn(Bool, *mut NSError)>>,
206 );
207
208 #[cfg(feature = "block2")]
209 /// Remove all existing credential identities from the store.
210 ///
211 /// Parameter `completion`: optional completion handler to be called after removing all existing credential identities.
212 /// If the operation fails, an error with domain ASCredentialIdentityStoreErrorDomain will be provided and none of
213 /// the existing credential identities will be removed from the store.
214 #[unsafe(method(removeAllCredentialIdentitiesWithCompletion:))]
215 #[unsafe(method_family = none)]
216 pub unsafe fn removeAllCredentialIdentitiesWithCompletion(
217 &self,
218 completion: Option<&block2::DynBlock<dyn Fn(Bool, *mut NSError)>>,
219 );
220
221 #[cfg(all(feature = "ASPasswordCredentialIdentity", feature = "block2"))]
222 /// Replace existing credential identities with new credential identities.
223 ///
224 /// Parameter `newCredentialIdentities`: array of new credential identity objects to replace the old ones.
225 ///
226 /// Parameter `completion`: an optional completion block to be called after the operation is finished.
227 ///
228 /// This method will delete all existing credential identities that are persisted in the
229 /// store and replace them with the provided array of credential identities. If the operation fails, an
230 /// error with domain ASCredentialIdentityStoreErrorDomain will be provided and none of the new credential
231 /// identities will be saved.
232 #[deprecated]
233 #[unsafe(method(replaceCredentialIdentitiesWithIdentities:completion:))]
234 #[unsafe(method_family = none)]
235 pub unsafe fn replaceCredentialIdentitiesWithIdentities_completion(
236 &self,
237 new_credential_identities: &NSArray<ASPasswordCredentialIdentity>,
238 completion: Option<&block2::DynBlock<dyn Fn(Bool, *mut NSError)>>,
239 );
240
241 #[cfg(all(feature = "ASCredentialIdentity", feature = "block2"))]
242 /// Replace existing credential identities with new credential identities.
243 ///
244 /// Parameter `newCredentialIdentities`: array of new credential identity objects to replace the old ones.
245 ///
246 /// Parameter `completion`: an optional completion block to be called after the operation is finished.
247 ///
248 /// This method will delete all existing credential identities that are persisted in the
249 /// store and replace them with the provided array of credential identities. If the operation fails, an
250 /// error with domain ASCredentialIdentityStoreErrorDomain will be provided and none of the new credential
251 /// identities will be saved.
252 #[unsafe(method(replaceCredentialIdentityEntries:completion:))]
253 #[unsafe(method_family = none)]
254 pub unsafe fn replaceCredentialIdentityEntries_completion(
255 &self,
256 new_credential_identities: &NSArray<ProtocolObject<dyn ASCredentialIdentity>>,
257 completion: Option<&block2::DynBlock<dyn Fn(Bool, *mut NSError)>>,
258 );
259 );
260}
261
262/// Methods declared on superclass `NSObject`.
263impl ASCredentialIdentityStore {
264 extern_methods!(
265 #[unsafe(method(new))]
266 #[unsafe(method_family = new)]
267 pub unsafe fn new() -> Retained<Self>;
268 );
269}