objc2-open-directory 0.3.2

Bindings to the OpenDirectory 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
//! 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::*;
#[cfg(feature = "objc2-security-foundation")]
use objc2_security_foundation::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/opendirectory/odpacketsigningdisabled?language=objc)
pub const ODPacketSigningDisabled: c_uint = 0;
/// [Apple's documentation](https://developer.apple.com/documentation/opendirectory/odpacketsigningallow?language=objc)
pub const ODPacketSigningAllow: c_uint = 1;
/// [Apple's documentation](https://developer.apple.com/documentation/opendirectory/odpacketsigningrequired?language=objc)
pub const ODPacketSigningRequired: c_uint = 2;

/// [Apple's documentation](https://developer.apple.com/documentation/opendirectory/odpacketencryptiondisabled?language=objc)
pub const ODPacketEncryptionDisabled: c_uint = 0;
/// [Apple's documentation](https://developer.apple.com/documentation/opendirectory/odpacketencryptionallow?language=objc)
pub const ODPacketEncryptionAllow: c_uint = 1;
/// [Apple's documentation](https://developer.apple.com/documentation/opendirectory/odpacketencryptionrequired?language=objc)
pub const ODPacketEncryptionRequired: c_uint = 2;
/// [Apple's documentation](https://developer.apple.com/documentation/opendirectory/odpacketencryptionssl?language=objc)
pub const ODPacketEncryptionSSL: c_uint = 3;

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/opendirectory/odtrusttypejoined?language=objc)
    pub static ODTrustTypeJoined: Option<&'static NSString>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/opendirectory/odtrusttypeusingcredentials?language=objc)
    pub static ODTrustTypeUsingCredentials: Option<&'static NSString>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/opendirectory/odtrusttypeanonymous?language=objc)
    pub static ODTrustTypeAnonymous: Option<&'static NSString>;
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/opendirectory/odconfiguration?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct ODConfiguration;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for ODConfiguration {}
);

impl ODConfiguration {
    extern_methods!(
        #[unsafe(method(nodeName))]
        #[unsafe(method_family = none)]
        pub unsafe fn nodeName(&self) -> Retained<NSString>;

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

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

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

        #[cfg(feature = "ODMappings")]
        #[unsafe(method(defaultMappings))]
        #[unsafe(method_family = none)]
        pub unsafe fn defaultMappings(&self) -> Option<Retained<ODMappings>>;

        #[cfg(feature = "ODMappings")]
        /// Setter for [`defaultMappings`][Self::defaultMappings].
        ///
        /// # Safety
        ///
        /// `default_mappings` might not allow `None`.
        #[unsafe(method(setDefaultMappings:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDefaultMappings(&self, default_mappings: Option<&ODMappings>);

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

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

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

        /// Setter for [`virtualSubnodes`][Self::virtualSubnodes].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        ///
        /// # Safety
        ///
        /// `virtual_subnodes` generic should be of the correct type.
        #[unsafe(method(setVirtualSubnodes:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setVirtualSubnodes(&self, virtual_subnodes: Option<&NSArray>);

        #[unsafe(method(hideRegistration))]
        #[unsafe(method_family = none)]
        pub unsafe fn hideRegistration(&self) -> bool;

        /// Setter for [`hideRegistration`][Self::hideRegistration].
        #[unsafe(method(setHideRegistration:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setHideRegistration(&self, hide_registration: bool);

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

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

        #[unsafe(method(preferredDestinationHostPort))]
        #[unsafe(method_family = none)]
        pub unsafe fn preferredDestinationHostPort(&self) -> u16;

        /// Setter for [`preferredDestinationHostPort`][Self::preferredDestinationHostPort].
        #[unsafe(method(setPreferredDestinationHostPort:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPreferredDestinationHostPort(&self, preferred_destination_host_port: u16);

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

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

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

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

        #[unsafe(method(trustUsesMutualAuthentication))]
        #[unsafe(method_family = none)]
        pub unsafe fn trustUsesMutualAuthentication(&self) -> bool;

        #[unsafe(method(trustUsesKerberosKeytab))]
        #[unsafe(method_family = none)]
        pub unsafe fn trustUsesKerberosKeytab(&self) -> bool;

        #[unsafe(method(trustUsesSystemKeychain))]
        #[unsafe(method_family = none)]
        pub unsafe fn trustUsesSystemKeychain(&self) -> bool;

        #[unsafe(method(packetSigning))]
        #[unsafe(method_family = none)]
        pub unsafe fn packetSigning(&self) -> NSInteger;

        /// Setter for [`packetSigning`][Self::packetSigning].
        #[unsafe(method(setPacketSigning:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPacketSigning(&self, packet_signing: NSInteger);

        #[unsafe(method(packetEncryption))]
        #[unsafe(method_family = none)]
        pub unsafe fn packetEncryption(&self) -> NSInteger;

        /// Setter for [`packetEncryption`][Self::packetEncryption].
        #[unsafe(method(setPacketEncryption:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPacketEncryption(&self, packet_encryption: NSInteger);

        #[unsafe(method(manInTheMiddleProtection))]
        #[unsafe(method_family = none)]
        pub unsafe fn manInTheMiddleProtection(&self) -> bool;

        /// Setter for [`manInTheMiddleProtection`][Self::manInTheMiddleProtection].
        #[unsafe(method(setManInTheMiddleProtection:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setManInTheMiddleProtection(&self, man_in_the_middle_protection: bool);

        #[unsafe(method(queryTimeoutInSeconds))]
        #[unsafe(method_family = none)]
        pub unsafe fn queryTimeoutInSeconds(&self) -> NSInteger;

        /// Setter for [`queryTimeoutInSeconds`][Self::queryTimeoutInSeconds].
        #[unsafe(method(setQueryTimeoutInSeconds:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setQueryTimeoutInSeconds(&self, query_timeout_in_seconds: NSInteger);

        #[unsafe(method(connectionSetupTimeoutInSeconds))]
        #[unsafe(method_family = none)]
        pub unsafe fn connectionSetupTimeoutInSeconds(&self) -> NSInteger;

        /// Setter for [`connectionSetupTimeoutInSeconds`][Self::connectionSetupTimeoutInSeconds].
        #[unsafe(method(setConnectionSetupTimeoutInSeconds:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setConnectionSetupTimeoutInSeconds(
            &self,
            connection_setup_timeout_in_seconds: NSInteger,
        );

        #[unsafe(method(connectionIdleTimeoutInSeconds))]
        #[unsafe(method_family = none)]
        pub unsafe fn connectionIdleTimeoutInSeconds(&self) -> NSInteger;

        /// Setter for [`connectionIdleTimeoutInSeconds`][Self::connectionIdleTimeoutInSeconds].
        #[unsafe(method(setConnectionIdleTimeoutInSeconds:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setConnectionIdleTimeoutInSeconds(
            &self,
            connection_idle_timeout_in_seconds: NSInteger,
        );

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

        /// Setter for [`defaultModuleEntries`][Self::defaultModuleEntries].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        ///
        /// # Safety
        ///
        /// `default_module_entries` generic should be of the correct type.
        #[unsafe(method(setDefaultModuleEntries:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDefaultModuleEntries(&self, default_module_entries: Option<&NSArray>);

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

        /// Setter for [`authenticationModuleEntries`][Self::authenticationModuleEntries].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        ///
        /// # Safety
        ///
        /// `authentication_module_entries` generic should be of the correct type.
        #[unsafe(method(setAuthenticationModuleEntries:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAuthenticationModuleEntries(
            &self,
            authentication_module_entries: Option<&NSArray>,
        );

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

        /// Setter for [`discoveryModuleEntries`][Self::discoveryModuleEntries].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        ///
        /// # Safety
        ///
        /// `discovery_module_entries` generic should be of the correct type.
        #[unsafe(method(setDiscoveryModuleEntries:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDiscoveryModuleEntries(&self, discovery_module_entries: Option<&NSArray>);

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

        /// Setter for [`generalModuleEntries`][Self::generalModuleEntries].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        ///
        /// # Safety
        ///
        /// `general_module_entries` generic should be of the correct type.
        #[unsafe(method(setGeneralModuleEntries:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setGeneralModuleEntries(&self, general_module_entries: Option<&NSArray>);

        /// Returns an initialized and autoreleased ODConfiguration object.
        ///
        ///
        /// Returns an initialized and autoreleased ODConfiguration object.
        #[unsafe(method(configuration))]
        #[unsafe(method_family = none)]
        pub unsafe fn configuration() -> Option<Retained<Self>>;

        /// Returns a suggested name to use for the trust account.
        ///
        ///
        /// Returns a suggested name to use for a trust account.  This name will be derived from the hostname
        /// (if provided), otherwise it will be derived from the local hostname removing special characters
        /// that may not be allowed by many systems.
        ///
        /// # Safety
        ///
        /// `hostname` might not allow `None`.
        #[unsafe(method(suggestedTrustAccount:))]
        #[unsafe(method_family = none)]
        pub unsafe fn suggestedTrustAccount(
            hostname: Option<&NSString>,
        ) -> Option<Retained<NSString>>;

        /// Returns a suggested password to be used for trust account with the requested length.
        ///
        ///
        /// Returns a suggested password to be used for trust account with the requested length.
        #[unsafe(method(suggestedTrustPassword:))]
        #[unsafe(method_family = none)]
        pub unsafe fn suggestedTrustPassword(length: usize) -> Option<Retained<NSString>>;

        #[cfg(feature = "objc2-security-foundation")]
        /// Saves the configuration using the provided authorization.
        ///
        ///
        /// Saves the configuration using the provided authorization.
        ///
        /// # Safety
        ///
        /// - `authorization` might not allow `None`.
        /// - `error` might not allow `None`.
        #[unsafe(method(saveUsingAuthorization:error:))]
        #[unsafe(method_family = none)]
        pub unsafe fn saveUsingAuthorization_error(
            &self,
            authorization: Option<&SFAuthorization>,
            error: Option<&mut Option<Retained<NSError>>>,
        ) -> bool;

        /// Adds a trust account with the provided name and password using the credentials provided by the user.
        ///
        ///
        /// Adds a trust account with the provided name and password using the credentials provided by the user.  User can
        /// request that the trust be forcibly created (replacing existing trust if found in directory).  A trust should be
        /// established only after enough configuration is available and the configuration been saved.  If the trust is
        /// required, then the configuration can be deleted if necessary upon failure.
        ///
        /// # Safety
        ///
        /// - `trust_type` might not allow `None`.
        /// - `account` might not allow `None`.
        /// - `account_password` might not allow `None`.
        /// - `username` might not allow `None`.
        /// - `password` might not allow `None`.
        /// - `error` might not allow `None`.
        #[unsafe(method(addTrustType:trustAccount:trustPassword:username:password:joinExisting:error:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addTrustType_trustAccount_trustPassword_username_password_joinExisting_error(
            &self,
            trust_type: Option<&NSString>,
            account: Option<&NSString>,
            account_password: Option<&NSString>,
            username: Option<&NSString>,
            password: Option<&NSString>,
            join: bool,
            error: Option<&mut Option<Retained<NSError>>>,
        ) -> bool;

        /// Removes trust using the provided username and password.
        ///
        ///
        /// Removes trust using the provided username and password.  The trust account will be removed from the directory only if requested.
        ///
        /// # Safety
        ///
        /// - `username` might not allow `None`.
        /// - `password` might not allow `None`.
        /// - `error` might not allow `None`.
        #[unsafe(method(removeTrustUsingUsername:password:deleteTrustAccount:error:))]
        #[unsafe(method_family = none)]
        pub unsafe fn removeTrustUsingUsername_password_deleteTrustAccount_error(
            &self,
            username: Option<&NSString>,
            password: Option<&NSString>,
            delete_account: bool,
            error: Option<&mut Option<Retained<NSError>>>,
        ) -> bool;
    );
}

/// Methods declared on superclass `NSObject`.
impl ODConfiguration {
    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>;
    );
}