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
//! 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_protocol!(
/// The delegate method for receiving query results from the NSRunLoop-based queries
///
/// The delegate method called as results are returned from an NSRunLoop-based query. These results are only partial
/// and delegate is called repeatedly as results are available. The incoming result must be retained or copied. The
/// array will be released by the NSRunLoop upon return. Incoming results do not include previous results,
/// only the most resent results are returned. inResults can be nil if an error occurs or the query is complete. If
/// inResults and inError are nil then the query has completed.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/opendirectory/odquerydelegate?language=objc)
pub unsafe trait ODQueryDelegate: NSObjectProtocol {
/// # Safety
///
/// - `in_query` might not allow `None`.
/// - `in_results` generic should be of the correct type.
/// - `in_results` might not allow `None`.
/// - `in_error` might not allow `None`.
#[unsafe(method(query:foundResults:error:))]
#[unsafe(method_family = none)]
unsafe fn query_foundResults_error(
&self,
in_query: Option<&ODQuery>,
in_results: Option<&NSArray>,
in_error: Option<&NSError>,
);
}
);
extern_class!(
/// Class used for querying OpenDirectory.
///
/// OpenDirectory queries may be used to search for different types of records, e.g. users, groups.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/opendirectory/odquery?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct ODQuery;
);
extern_conformance!(
unsafe impl NSCopying for ODQuery {}
);
unsafe impl CopyingHelper for ODQuery {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for ODQuery {}
);
impl ODQuery {
extern_methods!(
#[cfg(all(
feature = "CFOpenDirectory",
feature = "CFOpenDirectoryConstants",
feature = "ODNode"
))]
/// Creates an autoreleased query with the node using the parameters provided
///
/// Creates an autoreleased query with the node using the supplied query parameters. Some parameters
/// can either be NSString or NSData or an NSArray of either NSString or NSData. Passing nil for
/// returnAttributes is equivalent to passing kODAttributeTypeStandardOnly. outError is optional parameter,
/// nil can be passed if error details are not needed.
///
/// # Safety
///
/// - `in_node` might not allow `None`.
/// - `in_record_type_or_list` should be of the correct type.
/// - `in_record_type_or_list` might not allow `None`.
/// - `in_attribute` might not allow `None`.
/// - `in_query_value_or_list` should be of the correct type.
/// - `in_query_value_or_list` might not allow `None`.
/// - `in_return_attribute_or_list` should be of the correct type.
/// - `in_return_attribute_or_list` might not allow `None`.
/// - `out_error` might not allow `None`.
#[unsafe(method(queryWithNode:forRecordTypes:attribute:matchType:queryValues:returnAttributes:maximumResults:error:))]
#[unsafe(method_family = none)]
pub unsafe fn queryWithNode_forRecordTypes_attribute_matchType_queryValues_returnAttributes_maximumResults_error(
in_node: Option<&ODNode>,
in_record_type_or_list: Option<&AnyObject>,
in_attribute: Option<&ODAttributeType>,
in_match_type: ODMatchType,
in_query_value_or_list: Option<&AnyObject>,
in_return_attribute_or_list: Option<&AnyObject>,
in_maximum_results: NSInteger,
out_error: Option<&mut Option<Retained<NSError>>>,
) -> Option<Retained<ODQuery>>;
#[cfg(all(
feature = "CFOpenDirectory",
feature = "CFOpenDirectoryConstants",
feature = "ODNode"
))]
/// Creates a query with the node using the parameters provided
///
/// Creates a query with the node using the supplied query parameters. Some parameters
/// can either be NSString or NSData or an NSArray of either NSString or NSData. Passing nil for
/// returnAttributes is equivalent to passing kODAttributeTypeStandardOnly. outError is optional parameter,
/// nil can be passed if error details are not needed.
///
/// # Safety
///
/// - `in_node` might not allow `None`.
/// - `in_record_type_or_list` should be of the correct type.
/// - `in_record_type_or_list` might not allow `None`.
/// - `in_attribute` might not allow `None`.
/// - `in_query_value_or_list` should be of the correct type.
/// - `in_query_value_or_list` might not allow `None`.
/// - `in_return_attribute_or_list` should be of the correct type.
/// - `in_return_attribute_or_list` might not allow `None`.
/// - `out_error` might not allow `None`.
#[unsafe(method(initWithNode:forRecordTypes:attribute:matchType:queryValues:returnAttributes:maximumResults:error:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithNode_forRecordTypes_attribute_matchType_queryValues_returnAttributes_maximumResults_error(
this: Allocated<Self>,
in_node: Option<&ODNode>,
in_record_type_or_list: Option<&AnyObject>,
in_attribute: Option<&ODAttributeType>,
in_match_type: ODMatchType,
in_query_value_or_list: Option<&AnyObject>,
in_return_attribute_or_list: Option<&AnyObject>,
in_maximum_results: NSInteger,
out_error: Option<&mut Option<Retained<NSError>>>,
) -> Option<Retained<Self>>;
/// Returns results from a provided ODQuery synchronously
///
/// Returns results from a provided ODQuery synchronously. Passing NO to inAllowPartialResults
/// will block the call until all results are returned or an error occurs. YES can be passed at any time
/// even if previous calls were made with NO. outError is optional parameter, nil can be passed if error
/// details are not needed.
///
/// # Safety
///
/// `out_error` might not allow `None`.
#[unsafe(method(resultsAllowingPartial:error:))]
#[unsafe(method_family = none)]
pub unsafe fn resultsAllowingPartial_error(
&self,
in_allow_partial_results: bool,
out_error: Option<&mut Option<Retained<NSError>>>,
) -> Option<Retained<NSArray>>;
/// The currently set delegate
///
/// The query delegate which will receive asynchronous query results.
///
/// # Safety
///
/// This is not retained internally, you must ensure the object is still alive.
#[unsafe(method(delegate))]
#[unsafe(method_family = none)]
pub unsafe fn delegate(&self) -> Option<Retained<ProtocolObject<dyn ODQueryDelegate>>>;
/// Setter for [`delegate`][Self::delegate].
///
/// # Safety
///
/// - `delegate` might not allow `None`.
/// - This is unretained, you must ensure the object is kept alive while in use.
#[unsafe(method(setDelegate:))]
#[unsafe(method_family = none)]
pub unsafe fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn ODQueryDelegate>>);
/// Adds the query object to the specified NSRunLoop to receive asynchronous results
///
/// Adds the query object to the specified NSRunLoop to receive asynchronous results. A delegate must be set
/// in advance otherwise results may be lost due to the lack of a receiver.
///
/// # Safety
///
/// - `in_run_loop` possibly has additional threading requirements.
/// - `in_run_loop` might not allow `None`.
/// - `in_mode` might not allow `None`.
#[unsafe(method(scheduleInRunLoop:forMode:))]
#[unsafe(method_family = none)]
pub unsafe fn scheduleInRunLoop_forMode(
&self,
in_run_loop: Option<&NSRunLoop>,
in_mode: Option<&NSString>,
);
/// Removes the query object from the specified NSRunLoop
///
/// Removes the query object from the specified NSRunLoop.
///
/// # Safety
///
/// - `in_run_loop` possibly has additional threading requirements.
/// - `in_run_loop` might not allow `None`.
/// - `in_mode` might not allow `None`.
#[unsafe(method(removeFromRunLoop:forMode:))]
#[unsafe(method_family = none)]
pub unsafe fn removeFromRunLoop_forMode(
&self,
in_run_loop: Option<&NSRunLoop>,
in_mode: Option<&NSString>,
);
/// Will dispose of any results and restart the query.
///
/// Will dispose of any results and restart the query for subsequent resultsAllowingPartial: calls. If the query
/// is currently scheduled on a RunLoop, then the delegate will be called with inResults == nil and
/// [inError code] == kODErrorQuerySynchronize and [inError domain] == ODFrameworkErrorDomain, signifying that
/// all existing results should be thrown away in preparation for new results.
#[unsafe(method(synchronize))]
#[unsafe(method_family = none)]
pub unsafe fn synchronize(&self);
/// The NSOperationQueue on which asynchronous results are delivered to the delegate.
///
/// The NSOperationQueue on which asynchronous results are delivered to the delegate.
#[unsafe(method(operationQueue))]
#[unsafe(method_family = none)]
pub unsafe fn operationQueue(&self) -> Option<Retained<NSOperationQueue>>;
/// Setter for [`operationQueue`][Self::operationQueue].
///
/// # Safety
///
/// - `operation_queue` possibly has additional threading requirements.
/// - `operation_queue` might not allow `None`.
#[unsafe(method(setOperationQueue:))]
#[unsafe(method_family = none)]
pub unsafe fn setOperationQueue(&self, operation_queue: Option<&NSOperationQueue>);
);
}
/// Methods declared on superclass `NSObject`.
impl ODQuery {
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>;
);
}