objc2_foundation/generated/
NSNetServices.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9extern "C" {
10 #[cfg(feature = "NSString")]
12 pub static NSNetServicesErrorCode: &'static NSString;
13}
14
15extern "C" {
16 #[cfg(all(feature = "NSError", feature = "NSString"))]
18 pub static NSNetServicesErrorDomain: &'static NSErrorDomain;
19}
20
21#[repr(transparent)]
24#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
25pub struct NSNetServicesError(pub NSInteger);
26impl NSNetServicesError {
27 #[doc(alias = "NSNetServicesUnknownError")]
28 pub const UnknownError: Self = Self(-72000);
29 #[doc(alias = "NSNetServicesCollisionError")]
30 pub const CollisionError: Self = Self(-72001);
31 #[doc(alias = "NSNetServicesNotFoundError")]
32 pub const NotFoundError: Self = Self(-72002);
33 #[doc(alias = "NSNetServicesActivityInProgress")]
34 pub const ActivityInProgress: Self = Self(-72003);
35 #[doc(alias = "NSNetServicesBadArgumentError")]
36 pub const BadArgumentError: Self = Self(-72004);
37 #[doc(alias = "NSNetServicesCancelledError")]
38 pub const CancelledError: Self = Self(-72005);
39 #[doc(alias = "NSNetServicesInvalidError")]
40 pub const InvalidError: Self = Self(-72006);
41 #[doc(alias = "NSNetServicesTimeoutError")]
42 pub const TimeoutError: Self = Self(-72007);
43 #[doc(alias = "NSNetServicesMissingRequiredConfigurationError")]
44 pub const MissingRequiredConfigurationError: Self = Self(-72008);
45}
46
47unsafe impl Encode for NSNetServicesError {
48 const ENCODING: Encoding = NSInteger::ENCODING;
49}
50
51unsafe impl RefEncode for NSNetServicesError {
52 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
53}
54
55#[repr(transparent)]
58#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
59pub struct NSNetServiceOptions(pub NSUInteger);
60bitflags::bitflags! {
61 impl NSNetServiceOptions: NSUInteger {
62 #[doc(alias = "NSNetServiceNoAutoRename")]
63 const NoAutoRename = 1<<0;
64 #[doc(alias = "NSNetServiceListenForConnections")]
65 const ListenForConnections = 1<<1;
66 }
67}
68
69unsafe impl Encode for NSNetServiceOptions {
70 const ENCODING: Encoding = NSUInteger::ENCODING;
71}
72
73unsafe impl RefEncode for NSNetServiceOptions {
74 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
75}
76
77extern_class!(
78 #[unsafe(super(NSObject))]
80 #[derive(Debug, PartialEq, Eq, Hash)]
81 #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
82 pub struct NSNetService;
83);
84
85extern_conformance!(
86 unsafe impl NSObjectProtocol for NSNetService {}
87);
88
89impl NSNetService {
90 extern_methods!(
91 #[cfg(feature = "NSString")]
92 #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
93 #[unsafe(method(initWithDomain:type:name:port:))]
94 #[unsafe(method_family = init)]
95 pub unsafe fn initWithDomain_type_name_port(
96 this: Allocated<Self>,
97 domain: &NSString,
98 r#type: &NSString,
99 name: &NSString,
100 port: c_int,
101 ) -> Retained<Self>;
102
103 #[cfg(feature = "NSString")]
104 #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
105 #[unsafe(method(initWithDomain:type:name:))]
106 #[unsafe(method_family = init)]
107 pub unsafe fn initWithDomain_type_name(
108 this: Allocated<Self>,
109 domain: &NSString,
110 r#type: &NSString,
111 name: &NSString,
112 ) -> Retained<Self>;
113
114 #[cfg(all(feature = "NSObjCRuntime", feature = "NSRunLoop", feature = "NSString"))]
115 #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
116 #[unsafe(method(scheduleInRunLoop:forMode:))]
117 #[unsafe(method_family = none)]
118 pub unsafe fn scheduleInRunLoop_forMode(
119 &self,
120 a_run_loop: &NSRunLoop,
121 mode: &NSRunLoopMode,
122 );
123
124 #[cfg(all(feature = "NSObjCRuntime", feature = "NSRunLoop", feature = "NSString"))]
125 #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
126 #[unsafe(method(removeFromRunLoop:forMode:))]
127 #[unsafe(method_family = none)]
128 pub unsafe fn removeFromRunLoop_forMode(
129 &self,
130 a_run_loop: &NSRunLoop,
131 mode: &NSRunLoopMode,
132 );
133
134 #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
135 #[unsafe(method(delegate))]
136 #[unsafe(method_family = none)]
137 pub unsafe fn delegate(&self)
138 -> Option<Retained<ProtocolObject<dyn NSNetServiceDelegate>>>;
139
140 #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
142 #[unsafe(method(setDelegate:))]
143 #[unsafe(method_family = none)]
144 pub unsafe fn setDelegate(
145 &self,
146 delegate: Option<&ProtocolObject<dyn NSNetServiceDelegate>>,
147 );
148
149 #[unsafe(method(includesPeerToPeer))]
150 #[unsafe(method_family = none)]
151 pub unsafe fn includesPeerToPeer(&self) -> bool;
152
153 #[unsafe(method(setIncludesPeerToPeer:))]
155 #[unsafe(method_family = none)]
156 pub unsafe fn setIncludesPeerToPeer(&self, includes_peer_to_peer: bool);
157
158 #[cfg(feature = "NSString")]
159 #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
160 #[unsafe(method(name))]
161 #[unsafe(method_family = none)]
162 pub unsafe fn name(&self) -> Retained<NSString>;
163
164 #[cfg(feature = "NSString")]
165 #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
166 #[unsafe(method(type))]
167 #[unsafe(method_family = none)]
168 pub unsafe fn r#type(&self) -> Retained<NSString>;
169
170 #[cfg(feature = "NSString")]
171 #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
172 #[unsafe(method(domain))]
173 #[unsafe(method_family = none)]
174 pub unsafe fn domain(&self) -> Retained<NSString>;
175
176 #[cfg(feature = "NSString")]
177 #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
178 #[unsafe(method(hostName))]
179 #[unsafe(method_family = none)]
180 pub unsafe fn hostName(&self) -> Option<Retained<NSString>>;
181
182 #[cfg(all(feature = "NSArray", feature = "NSData"))]
183 #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
184 #[unsafe(method(addresses))]
185 #[unsafe(method_family = none)]
186 pub unsafe fn addresses(&self) -> Option<Retained<NSArray<NSData>>>;
187
188 #[unsafe(method(port))]
189 #[unsafe(method_family = none)]
190 pub unsafe fn port(&self) -> NSInteger;
191
192 #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
193 #[unsafe(method(publish))]
194 #[unsafe(method_family = none)]
195 pub unsafe fn publish(&self);
196
197 #[unsafe(method(publishWithOptions:))]
198 #[unsafe(method_family = none)]
199 pub unsafe fn publishWithOptions(&self, options: NSNetServiceOptions);
200
201 #[deprecated = "Not supported"]
202 #[unsafe(method(resolve))]
203 #[unsafe(method_family = none)]
204 pub unsafe fn resolve(&self);
205
206 #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
207 #[unsafe(method(stop))]
208 #[unsafe(method_family = none)]
209 pub unsafe fn stop(&self);
210
211 #[cfg(all(feature = "NSData", feature = "NSDictionary", feature = "NSString"))]
212 #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
213 #[unsafe(method(dictionaryFromTXTRecordData:))]
214 #[unsafe(method_family = none)]
215 pub unsafe fn dictionaryFromTXTRecordData(
216 txt_data: &NSData,
217 ) -> Retained<NSDictionary<NSString, NSData>>;
218
219 #[cfg(all(feature = "NSData", feature = "NSDictionary", feature = "NSString"))]
220 #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
221 #[unsafe(method(dataFromTXTRecordDictionary:))]
222 #[unsafe(method_family = none)]
223 pub unsafe fn dataFromTXTRecordDictionary(
224 txt_dictionary: &NSDictionary<NSString, NSData>,
225 ) -> Retained<NSData>;
226
227 #[cfg(feature = "NSDate")]
228 #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
229 #[unsafe(method(resolveWithTimeout:))]
230 #[unsafe(method_family = none)]
231 pub unsafe fn resolveWithTimeout(&self, timeout: NSTimeInterval);
232
233 #[cfg(feature = "NSStream")]
234 #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
235 #[unsafe(method(getInputStream:outputStream:))]
236 #[unsafe(method_family = none)]
237 pub unsafe fn getInputStream_outputStream(
238 &self,
239 input_stream: *mut *mut NSInputStream,
240 output_stream: *mut *mut NSOutputStream,
241 ) -> bool;
242
243 #[cfg(feature = "NSData")]
244 #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
245 #[unsafe(method(setTXTRecordData:))]
246 #[unsafe(method_family = none)]
247 pub unsafe fn setTXTRecordData(&self, record_data: Option<&NSData>) -> bool;
248
249 #[cfg(feature = "NSData")]
250 #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
251 #[unsafe(method(TXTRecordData))]
252 #[unsafe(method_family = none)]
253 pub unsafe fn TXTRecordData(&self) -> Option<Retained<NSData>>;
254
255 #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
256 #[unsafe(method(startMonitoring))]
257 #[unsafe(method_family = none)]
258 pub unsafe fn startMonitoring(&self);
259
260 #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
261 #[unsafe(method(stopMonitoring))]
262 #[unsafe(method_family = none)]
263 pub unsafe fn stopMonitoring(&self);
264 );
265}
266
267impl NSNetService {
269 extern_methods!(
270 #[unsafe(method(init))]
271 #[unsafe(method_family = init)]
272 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
273
274 #[unsafe(method(new))]
275 #[unsafe(method_family = new)]
276 pub unsafe fn new() -> Retained<Self>;
277 );
278}
279
280extern_class!(
281 #[unsafe(super(NSObject))]
283 #[derive(Debug, PartialEq, Eq, Hash)]
284 #[deprecated = "Use nw_browser_t in Network framework instead"]
285 pub struct NSNetServiceBrowser;
286);
287
288extern_conformance!(
289 unsafe impl NSObjectProtocol for NSNetServiceBrowser {}
290);
291
292impl NSNetServiceBrowser {
293 extern_methods!(
294 #[deprecated = "Use nw_browser_t in Network framework instead"]
295 #[unsafe(method(init))]
296 #[unsafe(method_family = init)]
297 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
298
299 #[deprecated = "Use nw_browser_t in Network framework instead"]
300 #[unsafe(method(delegate))]
301 #[unsafe(method_family = none)]
302 pub unsafe fn delegate(
303 &self,
304 ) -> Option<Retained<ProtocolObject<dyn NSNetServiceBrowserDelegate>>>;
305
306 #[deprecated = "Use nw_browser_t in Network framework instead"]
308 #[unsafe(method(setDelegate:))]
309 #[unsafe(method_family = none)]
310 pub unsafe fn setDelegate(
311 &self,
312 delegate: Option<&ProtocolObject<dyn NSNetServiceBrowserDelegate>>,
313 );
314
315 #[unsafe(method(includesPeerToPeer))]
316 #[unsafe(method_family = none)]
317 pub unsafe fn includesPeerToPeer(&self) -> bool;
318
319 #[unsafe(method(setIncludesPeerToPeer:))]
321 #[unsafe(method_family = none)]
322 pub unsafe fn setIncludesPeerToPeer(&self, includes_peer_to_peer: bool);
323
324 #[cfg(all(feature = "NSObjCRuntime", feature = "NSRunLoop", feature = "NSString"))]
325 #[deprecated = "Use nw_browser_t in Network framework instead"]
326 #[unsafe(method(scheduleInRunLoop:forMode:))]
327 #[unsafe(method_family = none)]
328 pub unsafe fn scheduleInRunLoop_forMode(
329 &self,
330 a_run_loop: &NSRunLoop,
331 mode: &NSRunLoopMode,
332 );
333
334 #[cfg(all(feature = "NSObjCRuntime", feature = "NSRunLoop", feature = "NSString"))]
335 #[deprecated = "Use nw_browser_t in Network framework instead"]
336 #[unsafe(method(removeFromRunLoop:forMode:))]
337 #[unsafe(method_family = none)]
338 pub unsafe fn removeFromRunLoop_forMode(
339 &self,
340 a_run_loop: &NSRunLoop,
341 mode: &NSRunLoopMode,
342 );
343
344 #[deprecated = "Use nw_browser_t in Network framework instead"]
345 #[unsafe(method(searchForBrowsableDomains))]
346 #[unsafe(method_family = none)]
347 pub unsafe fn searchForBrowsableDomains(&self);
348
349 #[deprecated = "Use nw_browser_t in Network framework instead"]
350 #[unsafe(method(searchForRegistrationDomains))]
351 #[unsafe(method_family = none)]
352 pub unsafe fn searchForRegistrationDomains(&self);
353
354 #[cfg(feature = "NSString")]
355 #[deprecated = "Use nw_browser_t in Network framework instead"]
356 #[unsafe(method(searchForServicesOfType:inDomain:))]
357 #[unsafe(method_family = none)]
358 pub unsafe fn searchForServicesOfType_inDomain(
359 &self,
360 r#type: &NSString,
361 domain_string: &NSString,
362 );
363
364 #[deprecated = "Use nw_browser_t in Network framework instead"]
365 #[unsafe(method(stop))]
366 #[unsafe(method_family = none)]
367 pub unsafe fn stop(&self);
368 );
369}
370
371impl NSNetServiceBrowser {
373 extern_methods!(
374 #[unsafe(method(new))]
375 #[unsafe(method_family = new)]
376 pub unsafe fn new() -> Retained<Self>;
377 );
378}
379
380extern_protocol!(
381 pub unsafe trait NSNetServiceDelegate: NSObjectProtocol {
383 #[optional]
384 #[unsafe(method(netServiceWillPublish:))]
385 #[unsafe(method_family = none)]
386 unsafe fn netServiceWillPublish(&self, sender: &NSNetService);
387
388 #[optional]
389 #[unsafe(method(netServiceDidPublish:))]
390 #[unsafe(method_family = none)]
391 unsafe fn netServiceDidPublish(&self, sender: &NSNetService);
392
393 #[cfg(all(feature = "NSDictionary", feature = "NSString", feature = "NSValue"))]
394 #[optional]
395 #[unsafe(method(netService:didNotPublish:))]
396 #[unsafe(method_family = none)]
397 unsafe fn netService_didNotPublish(
398 &self,
399 sender: &NSNetService,
400 error_dict: &NSDictionary<NSString, NSNumber>,
401 );
402
403 #[optional]
404 #[unsafe(method(netServiceWillResolve:))]
405 #[unsafe(method_family = none)]
406 unsafe fn netServiceWillResolve(&self, sender: &NSNetService);
407
408 #[optional]
409 #[unsafe(method(netServiceDidResolveAddress:))]
410 #[unsafe(method_family = none)]
411 unsafe fn netServiceDidResolveAddress(&self, sender: &NSNetService);
412
413 #[cfg(all(feature = "NSDictionary", feature = "NSString", feature = "NSValue"))]
414 #[optional]
415 #[unsafe(method(netService:didNotResolve:))]
416 #[unsafe(method_family = none)]
417 unsafe fn netService_didNotResolve(
418 &self,
419 sender: &NSNetService,
420 error_dict: &NSDictionary<NSString, NSNumber>,
421 );
422
423 #[optional]
424 #[unsafe(method(netServiceDidStop:))]
425 #[unsafe(method_family = none)]
426 unsafe fn netServiceDidStop(&self, sender: &NSNetService);
427
428 #[cfg(feature = "NSData")]
429 #[optional]
430 #[unsafe(method(netService:didUpdateTXTRecordData:))]
431 #[unsafe(method_family = none)]
432 unsafe fn netService_didUpdateTXTRecordData(&self, sender: &NSNetService, data: &NSData);
433
434 #[cfg(feature = "NSStream")]
435 #[optional]
436 #[unsafe(method(netService:didAcceptConnectionWithInputStream:outputStream:))]
437 #[unsafe(method_family = none)]
438 unsafe fn netService_didAcceptConnectionWithInputStream_outputStream(
439 &self,
440 sender: &NSNetService,
441 input_stream: &NSInputStream,
442 output_stream: &NSOutputStream,
443 );
444 }
445);
446
447extern_protocol!(
448 pub unsafe trait NSNetServiceBrowserDelegate: NSObjectProtocol {
450 #[optional]
451 #[unsafe(method(netServiceBrowserWillSearch:))]
452 #[unsafe(method_family = none)]
453 unsafe fn netServiceBrowserWillSearch(&self, browser: &NSNetServiceBrowser);
454
455 #[optional]
456 #[unsafe(method(netServiceBrowserDidStopSearch:))]
457 #[unsafe(method_family = none)]
458 unsafe fn netServiceBrowserDidStopSearch(&self, browser: &NSNetServiceBrowser);
459
460 #[cfg(all(feature = "NSDictionary", feature = "NSString", feature = "NSValue"))]
461 #[optional]
462 #[unsafe(method(netServiceBrowser:didNotSearch:))]
463 #[unsafe(method_family = none)]
464 unsafe fn netServiceBrowser_didNotSearch(
465 &self,
466 browser: &NSNetServiceBrowser,
467 error_dict: &NSDictionary<NSString, NSNumber>,
468 );
469
470 #[cfg(feature = "NSString")]
471 #[optional]
472 #[unsafe(method(netServiceBrowser:didFindDomain:moreComing:))]
473 #[unsafe(method_family = none)]
474 unsafe fn netServiceBrowser_didFindDomain_moreComing(
475 &self,
476 browser: &NSNetServiceBrowser,
477 domain_string: &NSString,
478 more_coming: bool,
479 );
480
481 #[optional]
482 #[unsafe(method(netServiceBrowser:didFindService:moreComing:))]
483 #[unsafe(method_family = none)]
484 unsafe fn netServiceBrowser_didFindService_moreComing(
485 &self,
486 browser: &NSNetServiceBrowser,
487 service: &NSNetService,
488 more_coming: bool,
489 );
490
491 #[cfg(feature = "NSString")]
492 #[optional]
493 #[unsafe(method(netServiceBrowser:didRemoveDomain:moreComing:))]
494 #[unsafe(method_family = none)]
495 unsafe fn netServiceBrowser_didRemoveDomain_moreComing(
496 &self,
497 browser: &NSNetServiceBrowser,
498 domain_string: &NSString,
499 more_coming: bool,
500 );
501
502 #[optional]
503 #[unsafe(method(netServiceBrowser:didRemoveService:moreComing:))]
504 #[unsafe(method_family = none)]
505 unsafe fn netServiceBrowser_didRemoveService_moreComing(
506 &self,
507 browser: &NSNetServiceBrowser,
508 service: &NSNetService,
509 more_coming: bool,
510 );
511 }
512);