objc2_open_directory/generated/
ODQuery.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_protocol!(
11    /// The delegate method for receiving query results from the NSRunLoop-based queries
12    ///
13    /// The delegate method called as results are returned from an NSRunLoop-based query.  These results are only partial
14    /// and delegate is called repeatedly as results are available.  The incoming result must be retained or copied.  The
15    /// array will be released by the NSRunLoop upon return.  Incoming results do not include previous results,
16    /// only the most resent results are returned.  inResults can be nil if an error occurs or the query is complete.  If
17    /// inResults and inError are nil then the query has completed.
18    ///
19    /// See also [Apple's documentation](https://developer.apple.com/documentation/opendirectory/odquerydelegate?language=objc)
20    pub unsafe trait ODQueryDelegate: NSObjectProtocol {
21        /// # Safety
22        ///
23        /// - `in_query` might not allow `None`.
24        /// - `in_results` generic should be of the correct type.
25        /// - `in_results` might not allow `None`.
26        /// - `in_error` might not allow `None`.
27        #[unsafe(method(query:foundResults:error:))]
28        #[unsafe(method_family = none)]
29        unsafe fn query_foundResults_error(
30            &self,
31            in_query: Option<&ODQuery>,
32            in_results: Option<&NSArray>,
33            in_error: Option<&NSError>,
34        );
35    }
36);
37
38extern_class!(
39    /// Class used for querying OpenDirectory.
40    ///
41    /// OpenDirectory queries may be used to search for different types of records, e.g. users, groups.
42    ///
43    /// See also [Apple's documentation](https://developer.apple.com/documentation/opendirectory/odquery?language=objc)
44    #[unsafe(super(NSObject))]
45    #[derive(Debug, PartialEq, Eq, Hash)]
46    pub struct ODQuery;
47);
48
49extern_conformance!(
50    unsafe impl NSCopying for ODQuery {}
51);
52
53unsafe impl CopyingHelper for ODQuery {
54    type Result = Self;
55}
56
57extern_conformance!(
58    unsafe impl NSObjectProtocol for ODQuery {}
59);
60
61impl ODQuery {
62    extern_methods!(
63        #[cfg(all(
64            feature = "CFOpenDirectory",
65            feature = "CFOpenDirectoryConstants",
66            feature = "ODNode"
67        ))]
68        /// Creates an autoreleased query with the node using the parameters provided
69        ///
70        /// Creates an autoreleased query with the node using the supplied query parameters.  Some parameters
71        /// can either be NSString or NSData or an NSArray of either NSString or NSData.  Passing nil for
72        /// returnAttributes is equivalent to passing kODAttributeTypeStandardOnly.  outError is optional parameter,
73        /// nil can be passed if error details are not needed.
74        ///
75        /// # Safety
76        ///
77        /// - `in_node` might not allow `None`.
78        /// - `in_record_type_or_list` should be of the correct type.
79        /// - `in_record_type_or_list` might not allow `None`.
80        /// - `in_attribute` might not allow `None`.
81        /// - `in_query_value_or_list` should be of the correct type.
82        /// - `in_query_value_or_list` might not allow `None`.
83        /// - `in_return_attribute_or_list` should be of the correct type.
84        /// - `in_return_attribute_or_list` might not allow `None`.
85        /// - `out_error` might not allow `None`.
86        #[unsafe(method(queryWithNode:forRecordTypes:attribute:matchType:queryValues:returnAttributes:maximumResults:error:))]
87        #[unsafe(method_family = none)]
88        pub unsafe fn queryWithNode_forRecordTypes_attribute_matchType_queryValues_returnAttributes_maximumResults_error(
89            in_node: Option<&ODNode>,
90            in_record_type_or_list: Option<&AnyObject>,
91            in_attribute: Option<&ODAttributeType>,
92            in_match_type: ODMatchType,
93            in_query_value_or_list: Option<&AnyObject>,
94            in_return_attribute_or_list: Option<&AnyObject>,
95            in_maximum_results: NSInteger,
96            out_error: Option<&mut Option<Retained<NSError>>>,
97        ) -> Option<Retained<ODQuery>>;
98
99        #[cfg(all(
100            feature = "CFOpenDirectory",
101            feature = "CFOpenDirectoryConstants",
102            feature = "ODNode"
103        ))]
104        /// Creates a query with the node using the parameters provided
105        ///
106        /// Creates a query with the node using the supplied query parameters.  Some parameters
107        /// can either be NSString or NSData or an NSArray of either NSString or NSData.  Passing nil for
108        /// returnAttributes is equivalent to passing kODAttributeTypeStandardOnly. outError is optional parameter,
109        /// nil can be passed if error details are not needed.
110        ///
111        /// # Safety
112        ///
113        /// - `in_node` might not allow `None`.
114        /// - `in_record_type_or_list` should be of the correct type.
115        /// - `in_record_type_or_list` might not allow `None`.
116        /// - `in_attribute` might not allow `None`.
117        /// - `in_query_value_or_list` should be of the correct type.
118        /// - `in_query_value_or_list` might not allow `None`.
119        /// - `in_return_attribute_or_list` should be of the correct type.
120        /// - `in_return_attribute_or_list` might not allow `None`.
121        /// - `out_error` might not allow `None`.
122        #[unsafe(method(initWithNode:forRecordTypes:attribute:matchType:queryValues:returnAttributes:maximumResults:error:))]
123        #[unsafe(method_family = init)]
124        pub unsafe fn initWithNode_forRecordTypes_attribute_matchType_queryValues_returnAttributes_maximumResults_error(
125            this: Allocated<Self>,
126            in_node: Option<&ODNode>,
127            in_record_type_or_list: Option<&AnyObject>,
128            in_attribute: Option<&ODAttributeType>,
129            in_match_type: ODMatchType,
130            in_query_value_or_list: Option<&AnyObject>,
131            in_return_attribute_or_list: Option<&AnyObject>,
132            in_maximum_results: NSInteger,
133            out_error: Option<&mut Option<Retained<NSError>>>,
134        ) -> Option<Retained<Self>>;
135
136        /// Returns results from a provided ODQuery synchronously
137        ///
138        /// Returns results from a provided ODQuery synchronously.  Passing NO to inAllowPartialResults
139        /// will block the call until all results are returned or an error occurs.  YES can be passed at any time
140        /// even if previous calls were made with NO.  outError is optional parameter, nil can be passed if error
141        /// details are not needed.
142        ///
143        /// # Safety
144        ///
145        /// `out_error` might not allow `None`.
146        #[unsafe(method(resultsAllowingPartial:error:))]
147        #[unsafe(method_family = none)]
148        pub unsafe fn resultsAllowingPartial_error(
149            &self,
150            in_allow_partial_results: bool,
151            out_error: Option<&mut Option<Retained<NSError>>>,
152        ) -> Option<Retained<NSArray>>;
153
154        /// The currently set delegate
155        ///
156        /// The query delegate which will receive asynchronous query results.
157        ///
158        /// # Safety
159        ///
160        /// This is not retained internally, you must ensure the object is still alive.
161        #[unsafe(method(delegate))]
162        #[unsafe(method_family = none)]
163        pub unsafe fn delegate(&self) -> Option<Retained<ProtocolObject<dyn ODQueryDelegate>>>;
164
165        /// Setter for [`delegate`][Self::delegate].
166        ///
167        /// # Safety
168        ///
169        /// - `delegate` might not allow `None`.
170        /// - This is unretained, you must ensure the object is kept alive while in use.
171        #[unsafe(method(setDelegate:))]
172        #[unsafe(method_family = none)]
173        pub unsafe fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn ODQueryDelegate>>);
174
175        /// Adds the query object to the specified NSRunLoop to receive asynchronous results
176        ///
177        /// Adds the query object to the specified NSRunLoop to receive asynchronous results.  A delegate must be set
178        /// in advance otherwise results may be lost due to the lack of a receiver.
179        ///
180        /// # Safety
181        ///
182        /// - `in_run_loop` possibly has additional threading requirements.
183        /// - `in_run_loop` might not allow `None`.
184        /// - `in_mode` might not allow `None`.
185        #[unsafe(method(scheduleInRunLoop:forMode:))]
186        #[unsafe(method_family = none)]
187        pub unsafe fn scheduleInRunLoop_forMode(
188            &self,
189            in_run_loop: Option<&NSRunLoop>,
190            in_mode: Option<&NSString>,
191        );
192
193        /// Removes the query object from the specified NSRunLoop
194        ///
195        /// Removes the query object from the specified NSRunLoop.
196        ///
197        /// # Safety
198        ///
199        /// - `in_run_loop` possibly has additional threading requirements.
200        /// - `in_run_loop` might not allow `None`.
201        /// - `in_mode` might not allow `None`.
202        #[unsafe(method(removeFromRunLoop:forMode:))]
203        #[unsafe(method_family = none)]
204        pub unsafe fn removeFromRunLoop_forMode(
205            &self,
206            in_run_loop: Option<&NSRunLoop>,
207            in_mode: Option<&NSString>,
208        );
209
210        /// Will dispose of any results and restart the query.
211        ///
212        /// Will dispose of any results and restart the query for subsequent resultsAllowingPartial: calls.  If the query
213        /// is currently scheduled on a RunLoop, then the delegate will be called with inResults == nil and
214        /// [inError code] == kODErrorQuerySynchronize and [inError domain] == ODFrameworkErrorDomain, signifying that
215        /// all existing results should be thrown away in preparation for new results.
216        #[unsafe(method(synchronize))]
217        #[unsafe(method_family = none)]
218        pub unsafe fn synchronize(&self);
219
220        /// The NSOperationQueue on which asynchronous results are delivered to the delegate.
221        ///
222        /// The NSOperationQueue on which asynchronous results are delivered to the delegate.
223        #[unsafe(method(operationQueue))]
224        #[unsafe(method_family = none)]
225        pub unsafe fn operationQueue(&self) -> Option<Retained<NSOperationQueue>>;
226
227        /// Setter for [`operationQueue`][Self::operationQueue].
228        ///
229        /// # Safety
230        ///
231        /// - `operation_queue` possibly has additional threading requirements.
232        /// - `operation_queue` might not allow `None`.
233        #[unsafe(method(setOperationQueue:))]
234        #[unsafe(method_family = none)]
235        pub unsafe fn setOperationQueue(&self, operation_queue: Option<&NSOperationQueue>);
236    );
237}
238
239/// Methods declared on superclass `NSObject`.
240impl ODQuery {
241    extern_methods!(
242        #[unsafe(method(init))]
243        #[unsafe(method_family = init)]
244        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
245
246        #[unsafe(method(new))]
247        #[unsafe(method_family = new)]
248        pub unsafe fn new() -> Retained<Self>;
249    );
250}