objc2_foundation/generated/
NSNetServices.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::*;
6
7use crate::*;
8
9extern "C" {
10    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsnetserviceserrorcode?language=objc)
11    #[cfg(feature = "NSString")]
12    pub static NSNetServicesErrorCode: &'static NSString;
13}
14
15extern "C" {
16    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsnetserviceserrordomain?language=objc)
17    #[cfg(all(feature = "NSError", feature = "NSString"))]
18    pub static NSNetServicesErrorDomain: &'static NSErrorDomain;
19}
20
21/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsnetserviceserror?language=objc)
22// NS_ENUM
23#[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/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsnetserviceoptions?language=objc)
56// NS_OPTIONS
57#[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    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsnetservice?language=objc)
79    #[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
85unsafe impl NSObjectProtocol for NSNetService {}
86
87impl NSNetService {
88    extern_methods!(
89        #[cfg(feature = "NSString")]
90        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
91        #[unsafe(method(initWithDomain:type:name:port:))]
92        #[unsafe(method_family = init)]
93        pub unsafe fn initWithDomain_type_name_port(
94            this: Allocated<Self>,
95            domain: &NSString,
96            r#type: &NSString,
97            name: &NSString,
98            port: c_int,
99        ) -> Retained<Self>;
100
101        #[cfg(feature = "NSString")]
102        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
103        #[unsafe(method(initWithDomain:type:name:))]
104        #[unsafe(method_family = init)]
105        pub unsafe fn initWithDomain_type_name(
106            this: Allocated<Self>,
107            domain: &NSString,
108            r#type: &NSString,
109            name: &NSString,
110        ) -> Retained<Self>;
111
112        #[cfg(all(feature = "NSObjCRuntime", feature = "NSRunLoop", feature = "NSString"))]
113        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
114        #[unsafe(method(scheduleInRunLoop:forMode:))]
115        #[unsafe(method_family = none)]
116        pub unsafe fn scheduleInRunLoop_forMode(
117            &self,
118            a_run_loop: &NSRunLoop,
119            mode: &NSRunLoopMode,
120        );
121
122        #[cfg(all(feature = "NSObjCRuntime", feature = "NSRunLoop", feature = "NSString"))]
123        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
124        #[unsafe(method(removeFromRunLoop:forMode:))]
125        #[unsafe(method_family = none)]
126        pub unsafe fn removeFromRunLoop_forMode(
127            &self,
128            a_run_loop: &NSRunLoop,
129            mode: &NSRunLoopMode,
130        );
131
132        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
133        #[unsafe(method(delegate))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn delegate(&self)
136            -> Option<Retained<ProtocolObject<dyn NSNetServiceDelegate>>>;
137
138        /// Setter for [`delegate`][Self::delegate].
139        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
140        #[unsafe(method(setDelegate:))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn setDelegate(
143            &self,
144            delegate: Option<&ProtocolObject<dyn NSNetServiceDelegate>>,
145        );
146
147        #[unsafe(method(includesPeerToPeer))]
148        #[unsafe(method_family = none)]
149        pub unsafe fn includesPeerToPeer(&self) -> bool;
150
151        /// Setter for [`includesPeerToPeer`][Self::includesPeerToPeer].
152        #[unsafe(method(setIncludesPeerToPeer:))]
153        #[unsafe(method_family = none)]
154        pub unsafe fn setIncludesPeerToPeer(&self, includes_peer_to_peer: bool);
155
156        #[cfg(feature = "NSString")]
157        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
158        #[unsafe(method(name))]
159        #[unsafe(method_family = none)]
160        pub unsafe fn name(&self) -> Retained<NSString>;
161
162        #[cfg(feature = "NSString")]
163        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
164        #[unsafe(method(type))]
165        #[unsafe(method_family = none)]
166        pub unsafe fn r#type(&self) -> Retained<NSString>;
167
168        #[cfg(feature = "NSString")]
169        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
170        #[unsafe(method(domain))]
171        #[unsafe(method_family = none)]
172        pub unsafe fn domain(&self) -> Retained<NSString>;
173
174        #[cfg(feature = "NSString")]
175        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
176        #[unsafe(method(hostName))]
177        #[unsafe(method_family = none)]
178        pub unsafe fn hostName(&self) -> Option<Retained<NSString>>;
179
180        #[cfg(all(feature = "NSArray", feature = "NSData"))]
181        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
182        #[unsafe(method(addresses))]
183        #[unsafe(method_family = none)]
184        pub unsafe fn addresses(&self) -> Option<Retained<NSArray<NSData>>>;
185
186        #[unsafe(method(port))]
187        #[unsafe(method_family = none)]
188        pub unsafe fn port(&self) -> NSInteger;
189
190        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
191        #[unsafe(method(publish))]
192        #[unsafe(method_family = none)]
193        pub unsafe fn publish(&self);
194
195        #[unsafe(method(publishWithOptions:))]
196        #[unsafe(method_family = none)]
197        pub unsafe fn publishWithOptions(&self, options: NSNetServiceOptions);
198
199        #[deprecated = "Not supported"]
200        #[unsafe(method(resolve))]
201        #[unsafe(method_family = none)]
202        pub unsafe fn resolve(&self);
203
204        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
205        #[unsafe(method(stop))]
206        #[unsafe(method_family = none)]
207        pub unsafe fn stop(&self);
208
209        #[cfg(all(feature = "NSData", feature = "NSDictionary", feature = "NSString"))]
210        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
211        #[unsafe(method(dictionaryFromTXTRecordData:))]
212        #[unsafe(method_family = none)]
213        pub unsafe fn dictionaryFromTXTRecordData(
214            txt_data: &NSData,
215        ) -> Retained<NSDictionary<NSString, NSData>>;
216
217        #[cfg(all(feature = "NSData", feature = "NSDictionary", feature = "NSString"))]
218        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
219        #[unsafe(method(dataFromTXTRecordDictionary:))]
220        #[unsafe(method_family = none)]
221        pub unsafe fn dataFromTXTRecordDictionary(
222            txt_dictionary: &NSDictionary<NSString, NSData>,
223        ) -> Retained<NSData>;
224
225        #[cfg(feature = "NSDate")]
226        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
227        #[unsafe(method(resolveWithTimeout:))]
228        #[unsafe(method_family = none)]
229        pub unsafe fn resolveWithTimeout(&self, timeout: NSTimeInterval);
230
231        #[cfg(feature = "NSStream")]
232        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
233        #[unsafe(method(getInputStream:outputStream:))]
234        #[unsafe(method_family = none)]
235        pub unsafe fn getInputStream_outputStream(
236            &self,
237            input_stream: *mut *mut NSInputStream,
238            output_stream: *mut *mut NSOutputStream,
239        ) -> bool;
240
241        #[cfg(feature = "NSData")]
242        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
243        #[unsafe(method(setTXTRecordData:))]
244        #[unsafe(method_family = none)]
245        pub unsafe fn setTXTRecordData(&self, record_data: Option<&NSData>) -> bool;
246
247        #[cfg(feature = "NSData")]
248        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
249        #[unsafe(method(TXTRecordData))]
250        #[unsafe(method_family = none)]
251        pub unsafe fn TXTRecordData(&self) -> Option<Retained<NSData>>;
252
253        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
254        #[unsafe(method(startMonitoring))]
255        #[unsafe(method_family = none)]
256        pub unsafe fn startMonitoring(&self);
257
258        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
259        #[unsafe(method(stopMonitoring))]
260        #[unsafe(method_family = none)]
261        pub unsafe fn stopMonitoring(&self);
262    );
263}
264
265/// Methods declared on superclass `NSObject`.
266impl NSNetService {
267    extern_methods!(
268        #[unsafe(method(init))]
269        #[unsafe(method_family = init)]
270        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
271
272        #[unsafe(method(new))]
273        #[unsafe(method_family = new)]
274        pub unsafe fn new() -> Retained<Self>;
275    );
276}
277
278extern_class!(
279    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsnetservicebrowser?language=objc)
280    #[unsafe(super(NSObject))]
281    #[derive(Debug, PartialEq, Eq, Hash)]
282    #[deprecated = "Use nw_browser_t in Network framework instead"]
283    pub struct NSNetServiceBrowser;
284);
285
286unsafe impl NSObjectProtocol for NSNetServiceBrowser {}
287
288impl NSNetServiceBrowser {
289    extern_methods!(
290        #[deprecated = "Use nw_browser_t in Network framework instead"]
291        #[unsafe(method(init))]
292        #[unsafe(method_family = init)]
293        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
294
295        #[deprecated = "Use nw_browser_t in Network framework instead"]
296        #[unsafe(method(delegate))]
297        #[unsafe(method_family = none)]
298        pub unsafe fn delegate(
299            &self,
300        ) -> Option<Retained<ProtocolObject<dyn NSNetServiceBrowserDelegate>>>;
301
302        /// Setter for [`delegate`][Self::delegate].
303        #[deprecated = "Use nw_browser_t in Network framework instead"]
304        #[unsafe(method(setDelegate:))]
305        #[unsafe(method_family = none)]
306        pub unsafe fn setDelegate(
307            &self,
308            delegate: Option<&ProtocolObject<dyn NSNetServiceBrowserDelegate>>,
309        );
310
311        #[unsafe(method(includesPeerToPeer))]
312        #[unsafe(method_family = none)]
313        pub unsafe fn includesPeerToPeer(&self) -> bool;
314
315        /// Setter for [`includesPeerToPeer`][Self::includesPeerToPeer].
316        #[unsafe(method(setIncludesPeerToPeer:))]
317        #[unsafe(method_family = none)]
318        pub unsafe fn setIncludesPeerToPeer(&self, includes_peer_to_peer: bool);
319
320        #[cfg(all(feature = "NSObjCRuntime", feature = "NSRunLoop", feature = "NSString"))]
321        #[deprecated = "Use nw_browser_t in Network framework instead"]
322        #[unsafe(method(scheduleInRunLoop:forMode:))]
323        #[unsafe(method_family = none)]
324        pub unsafe fn scheduleInRunLoop_forMode(
325            &self,
326            a_run_loop: &NSRunLoop,
327            mode: &NSRunLoopMode,
328        );
329
330        #[cfg(all(feature = "NSObjCRuntime", feature = "NSRunLoop", feature = "NSString"))]
331        #[deprecated = "Use nw_browser_t in Network framework instead"]
332        #[unsafe(method(removeFromRunLoop:forMode:))]
333        #[unsafe(method_family = none)]
334        pub unsafe fn removeFromRunLoop_forMode(
335            &self,
336            a_run_loop: &NSRunLoop,
337            mode: &NSRunLoopMode,
338        );
339
340        #[deprecated = "Use nw_browser_t in Network framework instead"]
341        #[unsafe(method(searchForBrowsableDomains))]
342        #[unsafe(method_family = none)]
343        pub unsafe fn searchForBrowsableDomains(&self);
344
345        #[deprecated = "Use nw_browser_t in Network framework instead"]
346        #[unsafe(method(searchForRegistrationDomains))]
347        #[unsafe(method_family = none)]
348        pub unsafe fn searchForRegistrationDomains(&self);
349
350        #[cfg(feature = "NSString")]
351        #[deprecated = "Use nw_browser_t in Network framework instead"]
352        #[unsafe(method(searchForServicesOfType:inDomain:))]
353        #[unsafe(method_family = none)]
354        pub unsafe fn searchForServicesOfType_inDomain(
355            &self,
356            r#type: &NSString,
357            domain_string: &NSString,
358        );
359
360        #[deprecated = "Use nw_browser_t in Network framework instead"]
361        #[unsafe(method(stop))]
362        #[unsafe(method_family = none)]
363        pub unsafe fn stop(&self);
364    );
365}
366
367/// Methods declared on superclass `NSObject`.
368impl NSNetServiceBrowser {
369    extern_methods!(
370        #[unsafe(method(new))]
371        #[unsafe(method_family = new)]
372        pub unsafe fn new() -> Retained<Self>;
373    );
374}
375
376extern_protocol!(
377    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsnetservicedelegate?language=objc)
378    pub unsafe trait NSNetServiceDelegate: NSObjectProtocol {
379        #[optional]
380        #[unsafe(method(netServiceWillPublish:))]
381        #[unsafe(method_family = none)]
382        unsafe fn netServiceWillPublish(&self, sender: &NSNetService);
383
384        #[optional]
385        #[unsafe(method(netServiceDidPublish:))]
386        #[unsafe(method_family = none)]
387        unsafe fn netServiceDidPublish(&self, sender: &NSNetService);
388
389        #[cfg(all(feature = "NSDictionary", feature = "NSString", feature = "NSValue"))]
390        #[optional]
391        #[unsafe(method(netService:didNotPublish:))]
392        #[unsafe(method_family = none)]
393        unsafe fn netService_didNotPublish(
394            &self,
395            sender: &NSNetService,
396            error_dict: &NSDictionary<NSString, NSNumber>,
397        );
398
399        #[optional]
400        #[unsafe(method(netServiceWillResolve:))]
401        #[unsafe(method_family = none)]
402        unsafe fn netServiceWillResolve(&self, sender: &NSNetService);
403
404        #[optional]
405        #[unsafe(method(netServiceDidResolveAddress:))]
406        #[unsafe(method_family = none)]
407        unsafe fn netServiceDidResolveAddress(&self, sender: &NSNetService);
408
409        #[cfg(all(feature = "NSDictionary", feature = "NSString", feature = "NSValue"))]
410        #[optional]
411        #[unsafe(method(netService:didNotResolve:))]
412        #[unsafe(method_family = none)]
413        unsafe fn netService_didNotResolve(
414            &self,
415            sender: &NSNetService,
416            error_dict: &NSDictionary<NSString, NSNumber>,
417        );
418
419        #[optional]
420        #[unsafe(method(netServiceDidStop:))]
421        #[unsafe(method_family = none)]
422        unsafe fn netServiceDidStop(&self, sender: &NSNetService);
423
424        #[cfg(feature = "NSData")]
425        #[optional]
426        #[unsafe(method(netService:didUpdateTXTRecordData:))]
427        #[unsafe(method_family = none)]
428        unsafe fn netService_didUpdateTXTRecordData(&self, sender: &NSNetService, data: &NSData);
429
430        #[cfg(feature = "NSStream")]
431        #[optional]
432        #[unsafe(method(netService:didAcceptConnectionWithInputStream:outputStream:))]
433        #[unsafe(method_family = none)]
434        unsafe fn netService_didAcceptConnectionWithInputStream_outputStream(
435            &self,
436            sender: &NSNetService,
437            input_stream: &NSInputStream,
438            output_stream: &NSOutputStream,
439        );
440    }
441);
442
443extern_protocol!(
444    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsnetservicebrowserdelegate?language=objc)
445    pub unsafe trait NSNetServiceBrowserDelegate: NSObjectProtocol {
446        #[optional]
447        #[unsafe(method(netServiceBrowserWillSearch:))]
448        #[unsafe(method_family = none)]
449        unsafe fn netServiceBrowserWillSearch(&self, browser: &NSNetServiceBrowser);
450
451        #[optional]
452        #[unsafe(method(netServiceBrowserDidStopSearch:))]
453        #[unsafe(method_family = none)]
454        unsafe fn netServiceBrowserDidStopSearch(&self, browser: &NSNetServiceBrowser);
455
456        #[cfg(all(feature = "NSDictionary", feature = "NSString", feature = "NSValue"))]
457        #[optional]
458        #[unsafe(method(netServiceBrowser:didNotSearch:))]
459        #[unsafe(method_family = none)]
460        unsafe fn netServiceBrowser_didNotSearch(
461            &self,
462            browser: &NSNetServiceBrowser,
463            error_dict: &NSDictionary<NSString, NSNumber>,
464        );
465
466        #[cfg(feature = "NSString")]
467        #[optional]
468        #[unsafe(method(netServiceBrowser:didFindDomain:moreComing:))]
469        #[unsafe(method_family = none)]
470        unsafe fn netServiceBrowser_didFindDomain_moreComing(
471            &self,
472            browser: &NSNetServiceBrowser,
473            domain_string: &NSString,
474            more_coming: bool,
475        );
476
477        #[optional]
478        #[unsafe(method(netServiceBrowser:didFindService:moreComing:))]
479        #[unsafe(method_family = none)]
480        unsafe fn netServiceBrowser_didFindService_moreComing(
481            &self,
482            browser: &NSNetServiceBrowser,
483            service: &NSNetService,
484            more_coming: bool,
485        );
486
487        #[cfg(feature = "NSString")]
488        #[optional]
489        #[unsafe(method(netServiceBrowser:didRemoveDomain:moreComing:))]
490        #[unsafe(method_family = none)]
491        unsafe fn netServiceBrowser_didRemoveDomain_moreComing(
492            &self,
493            browser: &NSNetServiceBrowser,
494            domain_string: &NSString,
495            more_coming: bool,
496        );
497
498        #[optional]
499        #[unsafe(method(netServiceBrowser:didRemoveService:moreComing:))]
500        #[unsafe(method_family = none)]
501        unsafe fn netServiceBrowser_didRemoveService_moreComing(
502            &self,
503            browser: &NSNetServiceBrowser,
504            service: &NSNetService,
505            more_coming: bool,
506        );
507    }
508);